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.

Related Posts:

  • Selenium Interview Questions and Answers I have attended some interviews during my career. I am sharing with you questions i was asked in the interviews. Hope these questions are helpful to the readers.    A Java Program to retrieve the data fro… Read More
  • Data Types in Java Based on the type of data stored, data types are classifying as 3 types in Java. Primitive Datatype (Fundamental Datatype): Derived Datatype User Defined Datatype Primitive Datatype (Fundamental Datatype):  The da… Read More
  • Variables and Methods Variables: Variable is a name given to a memory location in which, we can store some value which can be used in a program. Variable Declaration: It is process of specifying what type of data to be stored into the memory … Read More
  • Why Webdriver driver = new FirefoxDriver();        WebDriver driver =  new FirefoxDriver();                   (vs)        FirefoxDriver driver =  new Firef… Read More
  • Type Casting Type Casting: The process of converting value of one Datatype to another Datatype. Two ways of Casting: Widening:  Converting a smaller datatype to higher datatype is called widening. byte-> short -> char … Read More

0 comments:

Post a Comment

Selenium Training in Realtime

Blog helps to a student or IT employee to develop or improve skills in Software Testing.

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