Monday, July 29, 2019


       WebDriver drivernew FirefoxDriver();
                  (vs)
       FirefoxDriver drivernew FirefoxDriver();

WebDriver -> is an Interface
FirefoxDriver, ChromeDriver, IEDriver -> are classes

All the abstract methods of Webdriver interface are implemented in RemortWebDriver class which is extended by browser classes such as FirefoxDriver, ChromeDriver etc.,

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

selenium-repo by venu

Blog helps to a student or IT employee to develop or improve skills in Software Testing.
For Online Classes Email us: gadiparthi122@mail.com

Followers

About Me

My photo
Hyderabad, Andhra Pradesh, India
I am Automation Testing Professional. I have completed my graduation in B.Tech (Computers) from JNTU Hyderabad and started my career in Software Testing accidentally since then, I passionate on learning new technologies

Contact Form

Name

Email *

Message *

Popular Posts