Contents

Proposed architecture

Device visits the test server. If it is identified as being WebDriver-compatible (how do you do this identification still tba), the user is asked to enable WebDriver (how you do this seems device specific and potentially painful) and provide the remote's IP address (via an form input field?).

The test server connect to the device using the provided IP address.

The test server instructs the device to navigate to each test page it needs to run.

if the test page uses testharness.js, the results are sent back to the test server via the JSON protocol.

if the test page is a ref test, a screenshot is sent back to the test server and compared to the reference image there.

Once the tests are all run, the test server compiles the results and navigates the browser to the results page.

Using WebDriver to Test Devices

Problem:

We want to host a set of canonical webdriver tests on a publicly addressable server and run these against a device that may not be publicly addressable.

What We Know:

The server hosting the tests has a functioning web server.

All WebDriver implementations are required to have an implementation of the JSON over HTTP protocol listed in the W3C WebDriver spec.

The device being tested can access the Web.

The device being tested is behind a corporate firewall: it cannot be reached by the server.

The device adheres to the WebDriver spec.

It can be assumed that the people running the tests (the testers for wont of a better word) are minimally technical.

The tests hosted on the server are written using the language bindings of WebDriver and therefore represent the "local end" mentioned in the spec.

Options:

The obvious option, of having the tests run on the server and connecting to the device can't be followed because of the firewall. The following may be considered:

Option 1:

A simple "reflector" is created. This would be hosted on the same network as the device and would be implemented as a basic HTTP server. In order to run the tests, the following steps would be required:

The device's WebDriver mode would be enabled.

The testers would load the main page of the reflector. This would be a form, allowing the tester to input the URL used by the device for it's WebDriver JSON/HTTP implementation.

The reflector opens an HTTP connection to the server, asking to create a new testing session.

The server responds with the first WebDriver Command to execute and a key to identify this session with. This causes the HTTP connection to close. The reflector forwards the Command to the device, translating it to the JSON/HTTP protocol as necessary.

The device sends the WebDriver Response to the reflector, which opens a new HTTP request to the server and sends the Response and key back as the payload of that request.

The process of reflecting continues until the end of the tests.

Option 2:

The test scripts are hosted on the server but are actually run on the same network as the device, with results being uploaded to the server. The following steps would be required:

The testers set up a machine on the same network as the device and install python, easy_install and/or pip, as well as virtualenv

Install local end bindings for webdriver (probably the python selenium libs)

Download the full suite of tests from the server via HTTP(S)

Run each of those tests

(Optionally) Upload the results to the server.

Problems Not Considered:

What happens when the device is on a 3G/LTE network and is otherwise unreachable (that is, hosting a simple server or reflector on the same network is extremely hard to do) There are commercial and OSS tools that already do something similar, so it's possible.

The WebDriver JSON/HTTP protocol is very chatty. If we lose a single HTTP request or response then the entire test becomes invalid. We could mitigate this by using persistent HTTP connections or another technology entirely (websockets, perhaps?)