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, 2019 in Selenium by Karan

edited Jun 22, 2019 2,683 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 22, 2019 by Abha
• 28,140 points

Related Questions In Selenium

+1 vote
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,710 points
10,712 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 Jul 15, 2019 in Selenium by nayan
• 160 points
13,261 views
0 votes
2 answers

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,500 points
13,490 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,030 views
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,910 points
7,145 views
0 votes
2 answers

How to use such xpath to find web elements

xpath are two types. 1) Absolute XPath:    /html/b ...READ MORE

answered Sep 3, 2020 in Selenium by Sri
• 3,190 points
7,816 views
0 votes
1 answer

Why we need to use RemoteWebdriver Not the webdriver in Selenium Grid?

Hi Ramya, we use RemoteWebdriver in Selenium ...READ MORE

answered Jul 5, 2019 in Selenium by Abha
• 28,140 points
3,980 views
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, 2019 in Selenium by Abha
• 28,140 points
774 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP