All ChromeOS test images have ChromeDriver binary installed in
/usr/local/chromedriver/
. The binary is updated to the same version of Chrome
in that test image. That is, you always are using the latest build of
ChromeDriver.
If your test expects to run against a stable build of ChromeDriver binary,
you need to write your own code in your test to download the specific binary and
replace the binary in /usr/local/chromedriver/
.
Use ChromeDriver in an Autotest test
You can write a test that uses ChromeDriver to interact with ChromeOS. There's a wrapper class to use ChromeDriver available in ChromeOS/Autotest. The wrapper class acts as a context manager type and handles the following tasks for you:
- Signs into ChromeOS using Telemetry.
- Starts ChromeDriver with Remote mode on the Device under Test (DUT) and connects to the remote debug port of the Chrome instance after sign in.
- Exposes a driver instance for you to make any ChromeDriver calls.
- Shutdowns ChromeDriver process, and logs out of ChromeOS.
Follow this example of test: desktopui_UrlFetchWithChromeDriver
.
To get started:
Import the wrapper class.
from autotest_lib.client.common_lib.cros import chromedriver
Create an instance of the ChromeDriver and make calls.
with chromedriver.chromedriver() as chromedriver_instance: driver = chromedriver_instance.driver # Here you can make standard ChromeDriver calls through the driver instance. # For example, browse a given url with |driver.get(url)|