Selenium WebDriver with Internet Explorer and Google Chrome

Selenium WebDriver works very well with Mozilla Firefox because it has a built in driver server. But the same is not true for Internet Explorer and Google Chrome.

If you ever get the “the path to the driver executable must be set by the webdriver.ie.driver system property” error or its similarly worded Chrome equivalent, it means that you need to install the driver servers on your browser. The driver server manages the calls between the browsers and the Selenium wire protocol.

Luckily, the driver servers are easy to get.

The InternetExplorerDriver is a standalone server which implements WebDriver’s wire protocol. This driver has been tested with IE 6, 7, 8 and 9 on appropriate combinations of XP, Vista and Windows 7. You can download it from the following URL-

https://code.google.com/p/selenium/downloads/list

The downloaded file is an exe file, but you don’t install it like other exe files. Instead, you add the following lines of code above your Internet ExplorerDriver object:

[code]System.setProperty("webdriver.ie.driver","ieDriverpath");
driver=new InternetExplorerDriver();

// ieDriverPath is the path of your downloaded IEDriverServer file[/code]

Similarly,  Google Chrome doesn’t have a built-in server so you will need a Chrome driver server for communicating your Selenium code to the browser. You can download the Chrome driver server from the above Google Code URL. Then add the following code to your existing Selenium code:

[code]System.setProperty("webdriver.chrome.driver","chromeDriverPath");

driver=new ChromeDriver();

// chromeDriverPath is the path of your downloaded chromeDriverServer file[/code]

If you have any further troubles running your Selenium tests on Chrome, it may be worthwhile checking  the chromedriver release notes.

Let me know in the comments if you have any questions.