wptrunner Internals

class wptrunner.executors.base.CallbackHandler(logger, protocol, test_window)

Handle callbacks from testdriver-using tests.

The default implementation here makes sense for things that are roughly like WebDriver. Things that are more different to WebDriver may need to create a fully custom implementation.

class wptrunner.executors.base.ConnectionlessBaseProtocolPart(parent)
execute_script(script, asynchronous=False)

Execute javascript in the current Window.

Parameters
  • script (str) – The js source to execute. This is implicitly wrapped in a function.

  • asynchronous (bool) – Whether the script is asynchronous in the webdriver sense i.e. whether the return value is the result of the initial function call or if it waits for some callback.

Returns

The result of the script execution.

load(url)

Load a url in the current browsing context

Parameters

url – The url to load

set_timeout(timeout)

Set the timeout for script execution.

Parameters

timeout – Script timeout in seconds

set_window(handle)

Set the top level browsing context to one specified by a given handle.

Parameters

handle – A protocol-specific handle identifying a top level browsing context.

wait()

Wait indefinitely for the browser to close.

Returns

True to re-run the test, or False to continue with the next test

window_handles()

Get a list of handles to top-level browsing contexts

class wptrunner.executors.base.ConnectionlessProtocol(executor, browser)
after_connect()

Run any post-connection steps. This happens after the ProtocolParts are initalized so can depend on a fully-populated object.

connect()

Make a connection to the remote browser

class wptrunner.executors.base.CrashtestExecutor(logger, browser, server_config, timeout_multiplier=1, debug_info=None, **kwargs)
exception wptrunner.executors.base.ExecutorException(status, message)
class wptrunner.executors.base.PrintRefTestExecutor(logger, browser, server_config, timeout_multiplier=1, debug_info=None, **kwargs)
class wptrunner.executors.base.RefTestExecutor(logger, browser, server_config, timeout_multiplier=1, screenshot_cache=None, debug_info=None, **kwargs)
class wptrunner.executors.base.TestExecutor(logger, browser, server_config, timeout_multiplier=1, debug_info=None, **kwargs)

Abstract Base class for object that actually executes the tests in a specific browser. Typically there will be a different TestExecutor subclass for each test type and method of executing tests.

Parameters
  • browser – ExecutorBrowser instance providing properties of the browser that will be tested.

  • server_config – Dictionary of wptserve server configuration of the form stored in TestEnvironment.config

  • timeout_multiplier – Multiplier relative to base timeout to use when setting test timeout.

abstract do_test(test)

Test-type and protocol specific implementation of running a specific test.

Parameters

test – The test to run.

reset()

Re-initialize internal state to facilitate repeated test execution as implemented by the –rerun command-line argument.

run_test(test)

Run a particular test.

Parameters

test – The test to run

setup(runner)

Run steps needed before tests can be started e.g. connecting to browser instance

Parameters

runner – TestRunner instance that is going to run the tests

teardown()

Run cleanup steps after tests have finished

class wptrunner.executors.base.TestharnessExecutor(logger, browser, server_config, timeout_multiplier=1, debug_info=None, **kwargs)
class wptrunner.executors.base.WdspecExecutor(logger, browser, server_config, webdriver_binary, webdriver_args, timeout_multiplier=1, capabilities=None, debug_info=None, environ=None, **kwargs)
do_test(test)

Test-type and protocol specific implementation of running a specific test.

Parameters

test – The test to run.

setup(runner)

Run steps needed before tests can be started e.g. connecting to browser instance

Parameters

runner – TestRunner instance that is going to run the tests

class wptrunner.executors.base.WdspecProtocol(executor, browser)
after_connect()

Run any post-connection steps. This happens after the ProtocolParts are initalized so can depend on a fully-populated object.

connect()

Connect to browser via the HTTP server.

is_alive()

Test that the connection is still alive.

Because the remote communication happens over HTTP we need to make an explicit request to the remote. It is allowed for WebDriver spec tests to not have a WebDriver session, since this may be what is tested.

An HTTP request to an invalid path that results in a 404 is proof enough to us that the server is alive and kicking.

teardown()

Run cleanup steps after the tests are finished.

wptrunner.executors.base.get_pages(ranges_value, total_pages)

Get a set of page numbers to include in a print reftest.

Parameters
  • ranges_value – Parsed page ranges as a list e.g. [[1,2], [4], [6,None]]

  • total_pages – Integer total number of pages in the paginated output.

Retval

Set containing integer page numbers to include in the comparison e.g. for the example ranges value and 10 total pages this would be {1,2,4,6,7,8,9,10}

wptrunner.executors.base.hash_screenshots(screenshots)

Computes the sha1 checksum of a list of base64-encoded screenshots.

wptrunner.executors.base.strip_server(url)

Remove the scheme and netloc from a url, leaving only the path and any query or fragment.

url - the url to strip

e.g. http://example.org:8000/tests?id=1#2 becomes /tests?id=1#2