Skip to content

Commit

Permalink
Set custom default timeouts for WebDriver classic session
Browse files Browse the repository at this point in the history
  • Loading branch information
whimboo authored and jgraham committed Mar 20, 2023
1 parent 3426f51 commit 1a44d85
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
1 change: 1 addition & 0 deletions tools/wptrunner/wptrunner/executors/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,7 @@ def do_wdspec(self, path, timeout):
session_config = {"host": self.browser.host,
"port": self.browser.port,
"capabilities": self.capabilities,
"timeout_multiplier": self.timeout_multiplier,
"webdriver": {
"binary": self.webdriver_binary,
"args": self.webdriver_args
Expand Down
9 changes: 0 additions & 9 deletions webdriver/tests/get_timeouts/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@ def test_get_timeouts(session):
assert isinstance(value["pageLoad"], int)


def test_get_default_timeouts(session):
response = get_timeouts(session)

assert_success(response)
assert response.body["value"]["script"] == 30000
assert response.body["value"]["implicit"] == 0
assert response.body["value"]["pageLoad"] == 300000


def test_get_new_timeouts(session):
session.timeouts.script = 60
session.timeouts.implicit = 1
Expand Down
14 changes: 11 additions & 3 deletions webdriver/tests/support/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
from tests.support.http_request import HTTPRequest


SCRIPT_TIMEOUT = 1
PAGE_LOAD_TIMEOUT = 3
IMPLICIT_WAIT_TIMEOUT = 0

# The webdriver session can outlive a pytest session
_current_session = None


_custom_session = False


def pytest_configure(config):
# register the capabilities marker
config.addinivalue_line(
Expand Down Expand Up @@ -63,6 +64,7 @@ def full_configuration():
host - WebDriver server host.
port - WebDriver server port.
capabilites - Capabilites passed when creating the WebDriver session
timeout_multiplier - Multiplier for timeout values
webdriver - Dict with keys `binary`: path to webdriver binary, and
`args`: Additional command line arguments passed to the webdriver
binary. This doesn't include all the required arguments e.g. the
Expand Down Expand Up @@ -137,6 +139,12 @@ async def session(capabilities, configuration):
_current_session.window.size = defaults.WINDOW_SIZE
_current_session.window.position = defaults.WINDOW_POSITION

# Set default timeouts
multiplier = configuration["timeout_multiplier"]
_current_session.timeouts.implicit = IMPLICIT_WAIT_TIMEOUT * multiplier
_current_session.timeouts.page_load = PAGE_LOAD_TIMEOUT * multiplier
_current_session.timeouts.script = SCRIPT_TIMEOUT * multiplier

yield _current_session

cleanup_session(_current_session)
Expand Down

0 comments on commit 1a44d85

Please sign in to comment.