Checkout our demo site to practice selenium https://magento.softwaretestingboard.com/

0 like 0 dislike
383 views
by Master (1.2k points)
Why do we use the WebDriver interface instead of any specific class like FirefoxWebDriver, ChromeDriver while declaring driver?

Why

WebDriver driver = new FirefoxDriver();

and not

FirefoxDriver driver = new FirefoxDriver();

1 Answer

1 like 0 dislike
by Contributing Tester (32 points)

A variable declared as WebDriver interface type can be assigned with the objects of  multiple class types like FirefoxDriver, ChromeDriver, InternetExplorerDriver etc. 

But we cannot assign the object of FirefoxDriver class type to a variable declared of ChromeDriver class type.

Hence at Framework level inorder to run our automation scripts on a required browser type, we can simply assign the object of required Class types to the same WebDriver interface declared variable. 

- Arun Motoori (www.TutorialsNinja.com)


This site is for software testing professionals, where you can ask all your questions and get answers from 1300+ masters of the profession. Click here to submit yours now!

1.4k questions

1.6k answers

866 comments

1.9k users

...