Skip to content
This repository has been archived by the owner on Apr 23, 2020. It is now read-only.

Testing with Chrome

Matti Schneider edited this page Sep 22, 2015 · 13 revisions

Using Watai with Google Chrome

To test with Chrome, you will need to install another utility, chromedriver, to bridge the Selenium server to Google Chrome.

Installation

Under OS X with Homebrew

brew install chromedriver

Others

  1. Download the proper precompiled version for your platform from ChromeDriver’s downloads.
  2. Make the downloaded file executable (chmod a+x path/to/chromedriver).
  3. Place the downloaded executable in your PATH (mv path/to/chromedriver /usr/local/bin for example, for Unices), or set the webdriver.chrome.driver system property to the path of the executable.

Choosing Chrome as the target browser

Edit the config of your Watai test suite.

You will have to set the browser key (or the browserName key of the driverCapabilities hash) to "chrome".

// config.json
{
    "baseURL": "http://127.0.0.1:3000",
    "browser": "chrome"
}

Non-standard binary location

If your Chrome browser is not in its default installation location (i.e. you moved it after having installed it, or you installed it with a package manager), you will also need to give the path to its binary in the chromeOptions object of the driverCapabilities hash.

// config.json
{
    "driverCapabilities": {
        "chromeOptions": { "binary": "/path/to/Google Chrome" },
    }
}

For example, if you installed Chrome with brew cask:

// ~/.watai/config.json
{
    "driverCapabilities": {
        "chromeOptions": {
            "binary": "/opt/homebrew-cask/Caskroom/google-chrome/latest/Google Chrome.app/Contents/MacOS/Google Chrome",
        }
    }
}

Benefits

  1. Much faster browser start than Firefox, and faster browsing mean faster tests.
  2. Obviously, testing on Chrome, a rather common browser ;)

Limitations

Runaway processes

Even though Watai does its best to clean up after itself, there may be cases where the chromedriver process is not killed properly. After a set of testing sessions, you should therefore make sure no runaway processes are left, with killall chromedriver, for example.