HomeSelenium

Selenium Interview Question 21 – Explain the line of code WebDriver driver = new FirefoxDriver();

Selenium Interview Question 21 – Explain the line of code WebDriver driver = new FirefoxDriver();

<<Previous Question       <<1500 Plus Interview Questions>>       Next Question>>

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.

Next Steps:

  • > 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 ?

About Me > Arun Motoori

<<Previous Question       <<1500 Plus Interview Questions>>       Next Question>>

On a mission to contribute to the Software Testing Community in all possible ways.

Comments (0)

Leave a Reply

Your email address will not be published. Required fields are marked *

For FREE Testing Tutorials & Videos

X
Open chat
Contact Us on Whatsapp