gecko-dev/testing/geckodriver/doc/Testing.md

2.5 KiB
Raw Blame History

Testing geckodriver

We verify and test geckodriver in a couple of different ways. Since it is an implementation of the WebDriver web standard, we share a set of conformance tests with other browser vendors through the Web Platform Tests (WPT) initiative. This lets us ensure web compatibility between different WebDriver implementations for different browsers.

In addition to the WPT tests, geckodriver and webdriver have unit tests. These are written in Rust, but you must explicitly tell mach to build these by adding the following line to your mozconfig:

ac_add_options --enable-rust-tests

Tests can then be run like this:

% ./mach test testing/geckodriver

To run the more extensive WPT tests you can use mach, but first make sure you have built Firefox:

% ./mach build
% ./mach wpt testing/web-platform/tests/webdriver

As these are functional integration tests and pop up Firefox windows sporadically, a helpful tip is to surpress the window whilst you are running them by using Firefox headless mode:

% MOZ_HEADLESS=1 ./mach wpt testing/web-platform/tests/webdriver

In addition to the MOZ_HEADLESS output variable there is also MOZ_HEADLESS_WIDTH and MOZ_HEADLESS_HEIGHT to control the dimensions of the no-op virtual display. This is similar to using xvfb(1) which you may know from the X windowing system, but has the additional benefit of also working on macOS and Windows.

As you get in to development of geckodriver and Marionette you will increasingly grow to understand our love for trace-level logs. They provide us with the input—the HTTP requests—from the client (in WPTs case from the tests use of a custom WebDriver client), the translation geckodriver makes to the Marionette protocol, the log output from Marionette, its responses back to geckodriver, and finally the output—or the HTTP response—back to the client.

The trace-level logs can be surfaced by passing on the -vv flag to geckodriver through WPT:

% ./mach wpt --webdriver-arg=-vv testing/web-platform/tests/webdriver