WebDriver driver = new FirefoxDriver();
(vs)
WebDriver -> is an Interface
FirefoxDriver, ChromeDriver, IEDriver -> are classes
In the above first statements we are creating objects for the browser class and casting it to WebDriver interface reference variable.
In the statement FirefoxDriver driver = new FirefoxDriver();,
The FirefoxDriver instance which gets created will be only able to invoke and act on the methods implemented by FirefoxDriver.. Using this statement, we can run our scripts only on Firefox Browser
To act with other browsers we have to specifically create individual objects as below:
ChromeDriver driver = new ChromeDriver();
InternetExplorerDriver driver = new InternetExplorerDriver();
To achieve we go for
WebDriver driver = new FirefoxDriver();
Whenever object is creating for the browser class and casting it to same driver reference variable
It helps you when you do testing on multiple browsers.
This is happening in dynamically run time. So that we can dynamic Polymorphism is applying here.
0 comments:
Post a Comment