• Stars
    star
    191
  • Rank 202,877 (Top 4 %)
  • Language
    C++
  • Created almost 11 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Unofficial ChromeDriver mirror

ChromeDriver

This file contains high-level info about how ChromeDriver works and how to contribute. If you are looking for information on how to use ChromeDriver, please see the ChromeDriver user site.

ChromeDriver is an implementation of the WebDriver standard, which allows users to automate testing of their website across browsers.

Getting Started

ChromeDriver source code is located in the Chromium source repository, and shares the same build tools as Chromium. To build ChromeDriver, please first follow the instructions to download and build Chromium.

Once you have set up the build environment, build ChromeDriver by building the chromedriver target, e.g.,

autoninja -C out/Default chromedriver

This will create an executable binary in the build folder named chromedriver[.exe].

Once built, ChromeDriver can be used with various third-party libraries that support WebDriver protocol, including language bindings provided by Selenium.

Note that if your build target OS is Android (i.e., you have target_os = "android" in your args.gn file), you will need to use the following command to build ChromeDriver targeting the host system:

autoninja -C out/Default clang_x64/chromedriver

Verifying the Build

For testing purposes, ChromeDriver can be used interactively with python. The following is an example on Linux. It assumes that you downloaded Chromium repository at ~/chromium/src, and you used out/Default as the build location. You may need to adjust the paths if you used different locations. The following code uses our own testing API, not the commonly used Python binding provided by Selenium.

$ cd ~/chromium/src/chrome/test/chromedriver
$ export PYTHONPATH=$PWD:$PWD/server:$PWD/client
$ python3
>>> import server
>>> import chromedriver
>>> cd_server = server.Server('../../../out/Default/chromedriver')
>>> driver = chromedriver.ChromeDriver(cd_server.GetUrl(), cd_server.GetPid())
>>> driver.Load('http://www.google.com')
>>> driver.Quit()
>>> cd_server.Kill()

By default, ChromeDriver will look in its own directory for Chrome to use. If Chrome is not found there, it will use the system installed Chrome.

To use ChromeDriver with Chrome on Android pass the Android package name in the chromeOptions.androidPackage capability when creating the driver. You also need to have Android SDK's Android Debug Bridge (adb) server running. For more detailed instructions see the user site.

Architecture

ChromeDriver is shipped separately from Chrome. It controls Chrome out of process through DevTools. ChromeDriver is a standalone server which communicates with the WebDriver client via the WebDriver wire protocol, which is essentially synchronous JSON commands over HTTP. WebDriver clients are available in many languages, and many are available from the open source Selenium WebDriver project. ChromeDriver uses the webserver from net/server.

Additional information is available on the following pages:

Code structure (relative to this file)

  • (this directory): Implements chromedriver commands.

  • chrome/: A basic interface for controlling Chrome. Should not depend on or reference WebDriver-related code or concepts.

  • js/: Javascript helper scripts.

  • net/: Code to deal with network communication, such as connection to DevTools.

  • client/: Code for a python client.

  • server/: Code for the chromedriver server. A python wrapper to the chromedriver server.

  • test/: Integration tests.

Testing

There are several test suites for verifying ChromeDriver's correctness. For details, see the testing page.

Contributing

Find an open issue and submit a patch for review by an individual listed in the OWNERS file in this directory. Issues are tracked in ChromeDriver issue tracker.