utils.browser module

Core functionality for starting, restarting, and stopping a selenium browser.

class utils.browser.DuckwebQaClient[source]

Bases: object

selenium[source]
class utils.browser.DuckwebQaTestSetup[source]

Bases: object

A standin for mozwebqa’s TestSetup class

Pretends to be a mozwebqa TestSetup so we can uninstall mozwebqa whithout breaking old tests that aren’t yet converted.

Note

This should never be used, and places where it’s currently used should stop it.

default_implicit_wait[source]
selenium[source]
timeout[source]
class utils.browser.Wharf(wharf_url)[source]

Bases: object

checkin()[source]
checkout()[source]
renew()[source]
utils.browser.browser()[source]

callable that will always return the current browser instance

If None, no browser is running.

Returns:The current browser instance.
utils.browser.browser_session(*args, **kwds)[source]

A context manager that can be used to start and stop a browser.

Usage:

with browser_session as browser:
    # do stuff with browser here
# Browser will be closed here
utils.browser.ensure_browser_open()[source]

Ensures that there is a browser instance currently open

Will reuse an existing browser or start a new one as-needed

Returns:The current browser instance.
utils.browser.firefox_profile_tmpdir = None

After starting a firefox browser, this will be set to the temporary directory where files are downloaded.

utils.browser.quit()[source]

Close the current browser

Will silently fail if the current browser can’t be closed for any reason.

Note

If a browser can’t be closed, it’s usually because it has already been closed elsewhere.

utils.browser.start(webdriver_name=None, base_url=None, **kwargs)[source]

Starts a new web browser

If a previous browser was open, it will be closed before starting the new browser

Parameters:
  • webdriver_name – The name of the selenium Webdriver to use. Default: ‘Firefox’
  • base_url – Optional, will use utils.conf.env['base_url'] by default
  • **kwargs – Any additional keyword arguments will be passed to the webdriver constructor
utils.browser.wharf()[source]