How do you launch Chrome browser using Selenium WebDriver?


To run WebDriver for any browser, we need a browser and a selenium server jar file.

Mozilla Firefox browser is supported by-default by Selenium 2. For other browsers like IE and Chrome you need to follow some basic steps, before you are able to to launch them or automate them with WebDriver


First and foremost you need to download latest version of ChromeDriver server for webdriver. You can download latest version of ChromeDriver server from Download Chrome Server

Set System property for the Chrome browser .Add the an .exe path of the driver server for the individual browsers to run webdriver in any browser.

Note: ChromeDriver is a standalone server which implements WebDriver's wire protocol

Set the property for chrome driver, specify its location via the webdriver.chrome.driver as below.

System.setProperty("webdriver.chrome.driver", "pathofchromedriver\\chromedriver.exe");

Not doing so ( setting the path of the .xex in System.setProperty() method) will fetch you the following error

Error: The path to the driver executable must be set by the webdriver.chrome.driver system property

Note: You might get a message "starting chromedriver on port xxxxx only local connections are allowed"  when your start execution with chrome driver.

Architecture behind this implementation explains that Most driver implementations whether Chrome or IE create an HTTP server, the language bindings (Java / Python / . etc.) use a JsonWireProtocol to communicate with the driver, to automate the browser.

Steps to launch Chrome browser

1. Download latest version of ChromeDriver server for webdriver. You can download latest version of ChromeDriver server from Download Chrome Server

2. Import the following jars

   import org.openqa.selenium.WebDriver;

   import org.openqa.selenium.chrome.ChromeDrive;

3. Set System property for the Chrome browser in the following command

   System.setProperty(Key , Value)

   key − This is the name of the system property.

   value − This is the value of the system property

2. Add the an .exe path of the driver server for the individual browsers to run webdriver in any browser.

   Note: ChromeDriver is a standalone server which implements WebDriver's wire protocol

Set the property for chrome driver, specify its location via the webdriver.chrome.driver as below.

System.setProperty("webdriver.chrome.driver", "pathofchromedriver\\chromedriver.exe");

Not doing so ( setting the path of the .exe in System.setProperty() method) will fetch you the following error

Error: The path to the driver executable must be set by the webdriver.chrome.driver system property

Note: You might get a message "starting chromedriver on port xxxxx only local connections are allowed"  when your start execution with chrome driver.

Architecture behind : Most driver implementations whether Chrome or IE create an HTTP server, the language bindings (Java / Python / . etc.) use a JsonWireProtocol to communicate with the driver, to automate the browser.

    System.setProperty("webdriver.chrome.driver", driverPath+"chromedriver.exe");

    driver = new ChromeDriver();

Note : Please send me your questions in the comment section. I will do my best to clear any doubts you might have related to the topic above or any other.