tree: 38897c8a8f0f6ff493515cab6d69c30d4a743e36 [path history] [tgz]
  1. chrome/
  2. client/
  3. constants/
  4. docs/
  5. extension/
  6. js/
  7. log_replay/
  8. net/
  9. server/
  10. support/
  11. test/
  12. alert_commands.cc
  13. alert_commands.h
  14. basic_types.cc
  15. basic_types.h
  16. BUILD.gn
  17. capabilities.cc
  18. capabilities.h
  19. capabilities_unittest.cc
  20. chrome_launcher.cc
  21. chrome_launcher.h
  22. chrome_launcher_unittest.cc
  23. chrome_paths.py
  24. command.h
  25. command_listener.h
  26. command_listener_proxy.cc
  27. command_listener_proxy.h
  28. command_listener_proxy_unittest.cc
  29. commands.cc
  30. commands.h
  31. commands_unittest.cc
  32. cpp_source.py
  33. DEPS
  34. devtools_events_logger.cc
  35. devtools_events_logger.h
  36. element_commands.cc
  37. element_commands.h
  38. element_commands_unittest.cc
  39. element_util.cc
  40. element_util.h
  41. embed_extension_in_cpp.py
  42. embed_js_in_cpp.py
  43. embed_mobile_devices_in_cpp.py
  44. embed_networks_in_cpp.py
  45. embed_user_data_dir_in_cpp.py
  46. key_converter.cc
  47. key_converter.h
  48. key_converter_unittest.cc
  49. keycode_text_conversion.h
  50. keycode_text_conversion_mac.mm
  51. keycode_text_conversion_ozone.cc
  52. keycode_text_conversion_unittest.cc
  53. keycode_text_conversion_win.cc
  54. keycode_text_conversion_x.cc
  55. logging.cc
  56. logging.h
  57. logging_unittest.cc
  58. OWNERS
  59. performance_logger.cc
  60. performance_logger.h
  61. performance_logger_unittest.cc
  62. README.md
  63. session.cc
  64. session.h
  65. session_commands.cc
  66. session_commands.h
  67. session_commands_unittest.cc
  68. session_thread_map.h
  69. session_unittest.cc
  70. util.cc
  71. util.h
  72. util.py
  73. util_unittest.cc
  74. webauthn_commands.cc
  75. webauthn_commands.h
  76. window_commands.cc
  77. window_commands.h
  78. window_commands_unittest.cc
chrome/test/chromedriver/README.md

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

Build ChromeDriver by building the chromedriver target, e.g.,

ninja -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.

For testing purposes, ChromeDriver can be used interactively with python. The following code uses our own testing API, not the commonly used Python binding provided by Selenium.

$ export PYTHONPATH=<THIS_DIR>/server:<THIS_DIR>/client
$ python
>>> import server
>>> import chromedriver
>>> cd_server = server.Server('/path/to/chromedriver/executable')
>>> driver = chromedriver.ChromeDriver(cd_server.GetUrl())
>>> 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. The path to adb_commands.py and the adb tool from the Android SDK must be set in PATH. 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.

ChromeDriver has a main thread, called the command thread, an IO thread, and a thread per session. The webserver receives a request on the IO thread, which is sent to a handler on the command thread. The handler executes the appropriate command function, which completes asynchronously. The create session command may create a new thread for subsequent session-related commands, which will execute on the dedicated session thread synchronously. When a command is finished, it will invoke a callback, which will eventually make its way back to the IO thread as a HTTP response for the server to send.

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.

  • extension/: An extension used for automating the desktop browser.

  • test/: Integration tests.

Testing

There are several test suites for verifying ChromeDriver's correctness:

chromedriver_unittests

This is the unittest target, which runs on the commit queue on win/mac/linux. Tests should take a few milliseconds and be very stable.

ninja -C out/Default chromedriver_unittests
out/Default/chromedriver_unittests

python integration tests (test/run_py_tests.py)

These tests are maintained by the ChromeDriver team, and are intended to verify that ChromeDriver works correctly with Chrome. Run test/run_py_tests.py --help for more info. These are run on the commit queue on win/mac/linux.

ninja -C out/Default chrome chromedriver
<THIS_DIR>/test/run_py_tests.py --chromedriver=out/Default/chromedriver

WebDriver Java acceptance tests (test/run_java_tests.py)

These are integration tests from the WebDriver open source project which can be run via test/run_java_tests.py. They are not currently run on any bots, but will be included in the commit queue in the future. Run with --help for more info.

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.