Interview Questions

SELENIUM REAL TIME INTERVIEW QUESTIONS - Why we refer Firefox driver to the web driver inheritance.

Selenium WebDriver Interview question and Answers


(Continued from previous question...)

SELENIUM REAL TIME INTERVIEW QUESTIONS - Why we refer Firefox driver to the web driver inheritance.

web Driver driver = new FireFoxDriver();

WebDriver is an interface which contain several abstract methods such as get(...), findElamentBy(...) etc.

e simply create reference of web Driver and we can assign objects (Firefox driver, CromeDriver, IEDriver, Andriod driver etc) to it.
Ex :
WebDriver driver = new FireFoxDriver();-----------(1)
If we are using (1) we can do the same thing by using
FireFoxDriver driver = new FireFoxDriver();---------(2)
We can use (1) and (2) for same purpose but if we want to switch to another browser in same program
then again we have to create the object of other class as for example
CromeDriver driver = new CromeDriver();.
creating object of several class is not good. So we create the reference of WebDriver and
we assign the objects of another class as for example
WebDriver driver; // it is created only one time in the program
driver = new FireFoxDriver();// any where in the program
driver = new CromeDriver(); // any where in the program

(Continued on next question...)

Other Interview Questions