Selenium 2.0 WebDriver – ChromeDriver

Selenium 2.0 provides different webdriver bindings for each browsers.  For example, firefox has FirefoxDriver and internet explorer has InternetExplorerDriver.  Google Chrome has ChromeDriver bindings.  Implementation is little different but there is no major change.  Only we need to understand the way it works.

For the FirefoxDriver, we need not start the server for execution of tests in standalone machine but for the ChromeDriver we need to start the server first and then start executing the tests from Eclipse.  Client will interact with the server with JsonWireProtocol and thus we can invoke Chrome browser and execute the tests on it.

Following is an example of just a Google search which uses ChromeDriver implementation:

package com.selftechy.wdriverbasics;

 * Author - Seetaram Hegde
 * Copyrights - All rights reserved
import org.junit.*;
import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner;
import org.openqa.selenium.*;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class ChromeDriverEx {

  private static ChromeDriverService srv;
  private WebDriver driver;

  public static void StartServer() throws IOException {
	  //Below file path to Chrome browser should be changed accordingly
    srv = new ChromeDriverService.Builder()
        .usingChromeDriverExecutable(new File("F:\\Helios-Workspace\\WebDriver\\chromedriverServer\\chromedriver.exe"))

  public static void StopServer() {

  public void StartDriver() {
    driver = new RemoteWebDriver(srv.getUrl(),;

  public void StopDriver() {

  public void testChromeDriver() {
    WebElement searchEdit = driver.findElement("q"));
    searchEdit.sendKeys("Selftechy on google");

Before executing the above code, please make sure that the Chrome browser is installed on the machine and appropriate JAR files are configured to the build path.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.