gecko-dev/testing/webdriver
Andreas Tolfsen e5126976b6 Bug 1471201 - Increase webdriver HTTPD Keep-Alive timeout to 90s. r=automatedtester
Increasing geckodriver's Keep-Alive timeout duration to 90
seconds, from the default five seconds, will reduce the number of
HTTP connections a persistent-enabled client will have to make,
potentially boosting performance.

In more recent hyper versions the default is 90 seconds, which
means we can get rid of this line when hyper is upgraded.

This will help mitigate https://github.com/mozilla/geckodriver/issues/1304
but not fundamentally resolve it, due to a standard library bug in
Python 2.7's urllib.

MozReview-Commit-ID: 98AFDQgWfpw

--HG--
extra : rebase_source : 75ce5a143533134b60848f2351aab60778c53d78
2018-07-05 12:50:33 +01:00
..
src Bug 1471201 - Increase webdriver HTTPD Keep-Alive timeout to 90s. r=automatedtester 2018-07-05 12:50:33 +01:00
.gitignore webdriver: Merge pull request #25 from danlrobertson/nullable 2016-03-27 17:30:04 +01:00
.hgignore Bug 1368265 - Add testing/webdriver hgignore file. r=automatedtester 2017-09-03 17:19:37 +01:00
.travis.yml webdriver: Merge pull request #27 from jgraham/travis 2016-04-04 13:04:07 +01:00
Cargo.toml Bug 1441204 - Release webdriver crate 0.36.0. r=maja_zf 2018-06-14 13:28:33 -07:00
moz.build Bug 1412904 - fill in missing bugzilla_components in testing/webdriver. r=ato 2017-10-31 12:27:48 -04:00
README.md Bug 1368265 - Provide a webdriver README. r=automatedtester 2017-09-03 17:15:03 +01:00

webdriver library

The webdriver crate is a library implementation of the wire protocol for the W3C WebDriver standard written in Rust. WebDriver is a remote control interface that enables introspection and control of user agents. It provides a platform- and language-neutral wire protocol as a way for out-of-process programs to remotely instruct the behaviour of web browsers.

The webdriver library provides the formal types, error codes, type and bounds checks, and JSON marshaling conventions for correctly parsing and emitting the WebDriver protocol. It also provides an HTTP server where endpoints are mapped to the different WebDriver commands.

As of right now, this is an implementation for the server side of the WebDriver API in Rust, not the client side.

Building

The library is built using the usual Rust conventions:

% cargo build

To run the tests:

% cargo test

Usage

To start an HTTP server that handles incoming command requests, a request handler needs to be implemented. It takes an incoming WebDriverMessage and emits a WebDriverResponse:

impl WebDriverHandler for MyHandler {
    fn handle_command(
        &mut self,
        _: &Option<Session>,
        msg: WebDriverMessage,
    ) -> WebDriverResult<WebDriverResponse> {
        …
    }

    fn delete_session(&mut self, _: &Option<Session>) {
        …
    }
}

let addr = SocketAddr::new("localhost", 4444);
let handler = MyHandler {};
let server = webdriver::server::start(addr, handler, vec![])?;
info!("Listening on {}", server.socket);

It is also possible to provide so called extension commands by providing a vector of known extension routes, for which each new route needs to implement the WebDriverExtensionRoute trait. Each route needs to map to a WebDriverExtensionCommand:

pub enum MyExtensionRoute { HelloWorld }
pub enum MyExtensionCommand { HelloWorld }

impl WebDriverExtensionRoute for MyExtensionRoute {
    fn command(
        &self,
        captures: &Captures,
        body: &Json,
    ) -> WebDriverResult<WebDriverCommand<MyExtensionCommand>> {
        …
    }
}

let extension_routes = vec![
    (Method::Get, "/session/{sessionId}/moz/hello", MyExtensions::HelloWorld)
];

…

let server = webdriver::server::start(addr, handler, extension_routes[..])?;

Contact

The mailing list for webdriver discussion is tools-marionette@lists.mozilla.org (subscribe, archive).

There is also an IRC channel to talk about using and developing webdriver in #ateam on irc.mozilla.org.