Why do we create a reference variable of type Webdriver, not the actual browser type?

0 votes
Why do we create a reference variable of type Webdriver, not the actual browser type?
Jun 21 in Selenium by Karan

edited Jun 21 34 views

1 answer to this question.

0 votes

Hey Karan, we create a reference variable to webdriver type because we could use the same Webdriver variable to hold the object of any browser such as the ChromeDriver, IEDriver, or SafariDriver, etc. We follow this approach as it can work with any browser instance.

WebDriver driver = new FirefoxDriver();

WebDriver driver = new ChromeDriver()

The following method is also correct but it will work only with the Firefox.

FirefoxDriver driver = new FirefoxDriver();
answered Jun 21 by Abha
• 16,440 points

Related Questions In Selenium

0 votes
2 answers
0 votes
1 answer

How do i click on <input type=file> on any browser if i'm testing with Selenium Webdriver?

Does not matter which OS or which ...READ MORE

answered Apr 29, 2018 in Selenium by king_kenny
• 3,590 points
2,547 views
0 votes
2 answers

When executing my Jenkins tests with Selenium WebDriver, I do not see a GUI.

Hi eLiJha, I also faced the same issue ...READ MORE

answered 5 days ago in Selenium by nayan
• 160 points
561 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,050 points
259 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
629 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
257 views
0 votes
1 answer
0 votes
1 answer

What are some of the browser commands used in Selenium Webdriver?

Hi Nakul, some of the most frequently ...READ MORE

answered May 14 in Selenium by Abha
• 16,440 points
33 views