7.
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.
We 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
nyc explanation!!1
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThank you for the explanation Ruchi. I am new to Selenium and from what I understand here... WebDriver is an interface which implements classes like FirefoxDriver, chromedriver, etc right? Please correct me if I'm wrong!
ReplyDelete[http://selenium.googlecode.com/git/docs/api/java/org/openqa/selenium/WebDriver.html]
I believe WebDriver is a Parent class not the interface.C
ReplyDeleteWebdriver is a interface.
DeleteGood Explanation !!
ReplyDeleteBut what is the need of switch browser in a single class ?
User can open the same browser in new window right ?
Please explain.
to do compatibility testing in different browsers ,we can test same scenario in different browsers..
DeleteFirefoxDriver,ChromeDriver,,,,etc classes implements the WebDriver interface
ReplyDeleteFirefoxDriver,ChromeDriver...etc classed implements the WebDriver interface
ReplyDeleteNice it is!!
ReplyDeletein the above example we are creating the objects for many classes .like
ReplyDeletenew chromeDriver(),new FirefoxDriver(),are the object creation.i think you have to say creating many references (or) object variables is not so good so that is the reason we use web driver reference.
good
ReplyDeleteGood one.....
ReplyDelete