Explain the line of code WebDriver driver = new FirefoxDriver();
Watch the answer for this Selenium Interview Question in a detailed manner in the below youtube video:
Note: Don’t forget to subscribe to my Youtube channel here: Click here
Notes used for explanation in this Youtube video are provided after the video:
Notes used in the above Youtube Video:
The following are the points for understanding WebDriver driver = new FirefoxDriver();
- > WebDriver is an Interface in Selenium
- > FirefoxDriver is a Class in Selenium
- > In this statement, we have created an object for FirefoxDriver class using new keyword and assigned the created object to the reference variable of WebDriver interface.
To add more value to this question:
- > We should be using WebDriver driver = new FirefoxDriver(); over FirefoxDriver driver = new FirefoxDriver();
- > The reason behind it is, we can create a reusable method for launching the desired browser by passing the browser name to the reusable method.
- – This is only possible when assign the objects of FirefoxDriver, ChromeDriver and InternetExplorerDriver to WebDriver interface.
- > For more Selenium Interview Questions and answers, continue to the next post (Click on Next Post link below)
- > Check complete Selenium Interview Questions list here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?