| OLD | NEW |
| 1 This file contains high-level info about how ChromeDriver works and how to | 1 This file contains high-level info about how ChromeDriver works and how to |
| 2 contribute. | 2 contribute. |
| 3 | 3 |
| 4 ChromeDriver is an implementation of the WebDriver standard, | 4 ChromeDriver is an implementation of the WebDriver standard, |
| 5 which allows users to automate testing of their website across browsers. | 5 which allows users to automate testing of their website across browsers. |
| 6 | 6 |
| 7 See the user site at http://code.google.com/p/chromedriver. |
| 8 |
| 7 =====Getting started===== | 9 =====Getting started===== |
| 8 Build ChromeDriver by building the 'chromedriver2_server' target. This will | 10 Build ChromeDriver by building the 'chromedriver2_server' target. This will |
| 9 create an executable binary in the build folder named 'chromedriver2_server.exe' | 11 create an executable binary in the build folder named |
| 10 on Windows or 'chromedriver2_server' on Mac and Linux. | 12 'chromedriver2_server[.exe]'. |
| 11 | 13 |
| 12 Once built, ChromeDriver can be used interactively with python. | 14 Once built, ChromeDriver can be used interactively with python. |
| 13 | 15 |
| 14 $ export PYTHONPATH=<THIS_DIR>/server:<THIS_DIR>/client | 16 $ export PYTHONPATH=<THIS_DIR>/server:<THIS_DIR>/client |
| 15 $ python | 17 $ python |
| 16 >>> import server | 18 >>> import server |
| 17 >>> import chromedriver | 19 >>> import chromedriver |
| 18 >>> cd_server = server.Server('/path/to/chromedriver2_server/executable') | 20 >>> cd_server = server.Server('/path/to/chromedriver2_server/executable') |
| 19 >>> driver = chromedriver.ChromeDriver(cd_server.GetUrl()) | 21 >>> driver = chromedriver.ChromeDriver(cd_server.GetUrl()) |
| 20 >>> driver.Load('http://www.google.com') | 22 >>> driver.Load('http://www.google.com') |
| 21 >>> driver.Quit() | 23 >>> driver.Quit() |
| 22 >>> cd_server.Kill() | 24 >>> cd_server.Kill() |
| 23 | 25 |
| 24 ChromeDriver will use the system installed Chrome by default. | 26 ChromeDriver will use the system installed Chrome by default. |
| 25 | 27 |
| 26 To use ChromeDriver2 with Chrome on Android pass the Android package name in the | 28 To use ChromeDriver2 with Chrome on Android pass the Android package name in the |
| 27 chromeOptions.androidPackage capability when creating the driver. The path to | 29 chromeOptions.androidPackage capability when creating the driver. The path to |
| 28 adb_commands.py and the adb tool from the Android SDK must be set in PATH. For | 30 adb_commands.py and the adb tool from the Android SDK must be set in PATH. For |
| 29 more detailed instructions see the wiki: | 31 more detailed instructions see the wiki: |
| 30 https://code.google.com/p/chromedriver/wiki/ChromeDriver2forAndroid | 32 https://code.google.com/p/chromedriver/wiki/ChromeDriver2forAndroid |
| 31 | 33 |
| 32 =====Architecture===== | 34 =====Architecture===== |
| 33 ChromeDriver is shipped separately from Chrome. It controls Chrome out of | 35 ChromeDriver is shipped separately from Chrome. It controls Chrome out of |
| 34 process through DevTools (WebKit Inspector). ChromeDriver is a standalone server | 36 process through DevTools. ChromeDriver is a standalone server which |
| 35 executable which communicates via the WebDriver JSON wire protocol. This can be | 37 communicates with the WebDriver client via the WebDriver wire protocol, which |
| 36 used with the open source WebDriver client libraries. | 38 is essentially synchronous JSON commands over HTTP. WebDriver clients are |
| 39 available in many languages, and many are available from the open source |
| 40 selenium/webdriver project: http://code.google.com/p/selenium. |
| 37 | 41 |
| 38 When a new session is created, a new thread is started that is dedicated to the | 42 ChromeDriver has several threads. The webserver code, third_party/mongoose, |
| 39 session. All commands for the session runs on this thread. This thread is | 43 spawns a thread for the server socket and a certain amount of request handling |
| 40 stopped when the session is deleted. Besides, there is an IO thread and it is | 44 threads. When a request is received, the command is processed on the message |
| 41 used to keep reading incoming data from Chrome in the background. | 45 loop of the main thread, also called the command thread. Commands may be handled |
| 46 asynchronously on the command thread, but the request handler threads |
| 47 will block waiting for the response. One of the commands allows the user to |
| 48 create a session, which includes spawning a dedicated session thread. Session |
| 49 commands will be dispatched to the session thread and handled synchronously |
| 50 there. Lastly, there is an IO/net thread on which the net/ code operates. |
| 51 This is used to keep reading incoming data from Chrome in the background. |
| 42 | 52 |
| 43 =====Code structure===== | 53 =====Code structure===== |
| 44 Code under the 'chrome' subdirectory is intended to be unaware of WebDriver and | |
| 45 serve as a basic C++ interface for controlling Chrome remotely via DevTools. | |
| 46 As such, it should not have any WebDriver-related dependencies. | |
| 47 | |
| 48 1) chrome/test/chromedriver | 54 1) chrome/test/chromedriver |
| 49 Implements chromedriver commands. | 55 Implements chromedriver commands. |
| 50 | 56 |
| 51 2) chrome/test/chromedriver/chrome | 57 2) chrome/test/chromedriver/chrome |
| 52 Code to deal with chrome specific stuff, like starting Chrome on different OS | 58 A basic interface for controlling Chrome via DevTools. Should not have |
| 53 platforms, controlling Chrome via DevTools, handling events from DevTools, etc. | 59 knowledge about WebDriver, and thus not depend on chrome/test/chromedriver. |
| 54 | 60 |
| 55 3) chrome/test/chromedriver/js | 61 3) chrome/test/chromedriver/js |
| 56 Javascript helper scripts. | 62 Javascript helper scripts. |
| 57 | 63 |
| 58 4) chrome/test/chromedriver/net | 64 4) chrome/test/chromedriver/net |
| 59 Code to deal with network communication, such as connection to DevTools. | 65 Code to deal with network communication, such as connection to DevTools. |
| 60 | 66 |
| 61 5) chrome/test/chromedriver/client | 67 5) chrome/test/chromedriver/client |
| 62 Code for a python client. | 68 Code for a python client. |
| 63 | 69 |
| 64 6) chrome/test/chromedriver/server | 70 6) chrome/test/chromedriver/server |
| 65 Code for the chromedriver server. | 71 Code for the chromedriver server. |
| 66 A python wrapper to the chromedriver server. | 72 A python wrapper to the chromedriver server. |
| 67 | 73 |
| 68 7) chrome/test/chromedriver/extension | 74 7) chrome/test/chromedriver/extension |
| 69 An extension used for automating the desktop browser. | 75 An extension used for automating the desktop browser. |
| 70 | 76 |
| 71 8) chrome/test/chromedriver/third_party | 77 8) chrome/test/chromedriver/third_party |
| 72 Third party libraries used by chromedriver. | 78 Third party libraries used by chromedriver. |
| 73 | 79 |
| 80 9) third_party/mongoose |
| 81 The webserver for chromedriver. |
| 82 |
| 74 =====Testing===== | 83 =====Testing===== |
| 75 There are 4 test suites for verifying ChromeDriver's correctness: | 84 There are 4 test suites for verifying ChromeDriver's correctness: |
| 76 | 85 |
| 77 1) chromedriver2_unittests (chrome/chrome_tests.gypi) | 86 1) chromedriver2_unittests (chrome/chrome_tests.gypi) |
| 78 This is the unittest target, which runs on the main waterfall on win/mac/linux | 87 This is the unittest target, which runs on the main waterfall on win/mac/linux |
| 79 and can close the tree. It is also run on the commit queue and try bots by | 88 and can close the tree. It is also run on the commit queue and try bots by |
| 80 default. Tests should take a few milliseconds and be very stable. | 89 default. Tests should take a few milliseconds and be very stable. |
| 81 | 90 |
| 82 2) chromedriver2_tests (chrome/chrome_tests.gypi) | 91 2) chromedriver2_tests (chrome/chrome_tests.gypi) |
| 83 This is a collection of C++ medium sized tests which can be run optionally | 92 This is a collection of C++ medium sized tests which can be run optionally |
| 84 on the trybots. | 93 on the trybots. |
| 85 | 94 |
| 86 3) python tests | 95 3) python tests |
| 87 These are integration tests which can be found in run_py_tests.py. They are | 96 These are integration tests which can be found in run_py_tests.py. They are |
| 88 run on the chromium QA bots: | 97 run on the chromium QA bots: |
| 89 http://build.chromium.org/p/chromium.pyauto/waterfall | 98 http://build.chromium.org/p/chromium.pyauto/waterfall |
| 90 | 99 |
| 91 4) WebDriver Java acceptance tests | 100 4) WebDriver Java acceptance tests |
| 92 These are integration tests from the WebDriver open source project which can | 101 These are integration tests from the WebDriver open source project which can |
| 93 be run via run_java_tests.py. They are also run on the chromium QA bots. | 102 be run via run_java_tests.py. They are also run on the chromium QA bots. |
| 94 See http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/webdriver | 103 See http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/webdriver |
| 95 | 104 |
| 96 =====Contributing===== | 105 =====Contributing===== |
| 97 Find an open issue and submit a patch for review by an individual listed in | 106 Find an open issue and submit a patch for review by an individual listed in |
| 98 the OWNERS file in this directory. Issues are tracked in chromedriver's issue | 107 the OWNERS file in this directory. Issues are tracked in chromedriver's issue |
| 99 tracker: | 108 tracker: |
| 100 https://code.google.com/p/chromedriver/issues/list | 109 https://code.google.com/p/chromedriver/issues/list |
| OLD | NEW |