Can anyone please let me know the technical difference in implementation of different browser like Firefox, Chrome and IE webdriver in selenium webdriver??
-
They are different browsers?????? – Arran Jul 14 '14 at 08:31
-
Google it, you can get more info. if you're concerned about any thing particular, detail it. – Vignesh Paramasivam Jul 14 '14 at 13:21
-
I feel like people doesn't understand the question maybe, if webdriver is a standard why do we need to instantiate different classes for each one of them. I am guessing they don't follow the standard yet but no idea about exact differences. – Agustin Cautin Oct 12 '18 at 09:44
3 Answers
Each driver is used to automate the application in that particular browser.
For example, if you use FirefoxDriver, your automation script will run in Firefox browser.
Technically their implementation is different and based on WebDriver interface.

- 5,701
- 9
- 50
- 89
-
so for running any web application in different browser we have to change the whole code?? – marck Jul 14 '14 at 08:05
-
2no. you need to change which browser you want to use. not the entire code. – Vignesh Paramasivam Jul 14 '14 at 13:24
ChromeDriver
, InternetExplorerDriver
and FirefoxDriver
are implementation of WebDriver
interface. Each provides implementation corresponding to the appropriate browser.
You dont need to change the code when you change the browser. You can write the code using instance of WebDriver
and just change implementing object depending on the browser.
Like if you are using Firefox
WebDriver driver = new FirefoxDriver();
driver.get("SOME_RANDOM_URL");
driver.find("SOME_RANDOM_ELEMENT");
if you want to change browser to chrome
WebDriver driver = new ChromeDriver();
// rest of the code will remain same
This is called Programming to interfaces.
-
This sentence would be incorrect "You dont need to change the code when you change the browser." Some of the WebDrivers do not implement all command so need to use different flow. Question edited to mention this point. – Baha Jun 22 '17 at 11:26
The code remains the same except for the driver instances and paths you will be specifying; As you would have already known, for firefox, you don't need to download any drivers explicitly. You just create the driver instance as below -
a) Firefox -
driver = new FirefoxDriver();
b) IE - For IE, you need to download IE driver and then place it in your drive. You then include the driver path in your code as follows (replace with your driver path in code below) -
System.setProperty("webdriver.ie.driver","C:\\Program Files (x86)\\Internet Explorer\\IEDriverServer.exe");
driver = new InternetExplorerDriver();
c) Chrome - For Chrome again, you need to download chrome driver and then place it in your drive. You then include the driver path in your code as follows (replace with your driver path in code below)-
System.setProperty("webdriver.chrome.driver","C:\\Program Files (x86)\\Internet Explorer\\chromedriver.exe");
driver = new ChromeDriver();

- 158
- 4
- 11