Wednesday, June 11, 2014

What do you mean by WebDriver driver = new FirefoxDriver();

What do you mean by
WebDriver driver = new FirefoxDriver();

Ans- Here in this, WebDriver driver = new FirefoxDriver();
An instance of FirefoxDriver class has been created and the address of that instance has been stored in the WebDriver type driver variable. As soon as 'new' keyword create the instance in the heap area while execution it will open the firefox browser with default setting.
As well as FirefoxDriver class will implement all the methods of WebDriver interface.

2 comments:

  1. So driver is the variable of Webdriver and not instance.. right?

    ReplyDelete
  2. yes driver is the reference variable and upon assigning an object an instance of FirefoxDriver will be created.

    ReplyDelete