Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set custom default timeouts for WebDriver classic session #39034

Merged
merged 1 commit into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
whimboo marked this conversation as resolved.
Show resolved Hide resolved
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