Skip to content

Commit

Permalink
[wdspec] Only resize and re-position window in session setup and tear…
Browse files Browse the repository at this point in the history
…down if needed
  • Loading branch information
whimboo committed Jan 5, 2024
1 parent 1ebd964 commit dd03258
Show file tree
Hide file tree
Showing 19 changed files with 34 additions and 25 deletions.
1 change: 0 additions & 1 deletion webdriver/tests/bidi/browsing_context/print/margin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# META: timeout=long
from math import ceil
import pytest

Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/bidi/browsing_context/set_viewport/invalid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest

import webdriver.bidi.error as error
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/bidi/input/perform_actions/invalid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest
import pytest_asyncio

Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/bidi/script/call_function/invalid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest
import webdriver.bidi.error as error

Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/element_clear/clear.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest
from webdriver import WebElement

Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/fullscreen_window/stress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

import pytest

from tests.support.asserts import assert_success
Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/maximize_window/maximize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import (
document_hidden,
Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/maximize_window/stress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

import time

import pytest
Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/minimize_window/minimize.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

from tests.support.asserts import assert_error, assert_success
from tests.support.helpers import document_hidden, is_fullscreen, is_maximized

Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/minimize_window/stress.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

import pytest

from tests.support.asserts import assert_success
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/perform_actions/invalid.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest

from webdriver.error import InvalidArgumentException
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_mouse.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest

from webdriver.error import InvalidArgumentException, NoSuchWindowException, StaleElementReferenceException
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_pen.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest

from webdriver.error import NoSuchWindowException, StaleElementReferenceException
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/perform_actions/pointer_touch.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

import pytest

from webdriver.error import NoSuchWindowException, StaleElementReferenceException
Expand Down
2 changes: 0 additions & 2 deletions webdriver/tests/classic/perform_actions/sequence.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# META: timeout=long

from tests.classic.perform_actions.support.refine import get_events, get_keys


Expand Down
1 change: 0 additions & 1 deletion webdriver/tests/classic/release_actions/sequence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# META: timeout=long
import pytest

from tests.classic.release_actions.support.refine import get_events, get_keys
Expand Down
3 changes: 3 additions & 0 deletions webdriver/tests/classic/set_window_rect/set.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# META: timeout=long

# Longer timeout required due to a bug in Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4

import pytest

from webdriver.transport import Response
Expand Down
16 changes: 12 additions & 4 deletions webdriver/tests/support/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,12 @@ async def session(capabilities, configuration):

# Enforce a fixed default window size and position
if _current_session.capabilities.get("setWindowRect"):
_current_session.window.size = defaults.WINDOW_SIZE
_current_session.window.position = defaults.WINDOW_POSITION
# Only resize and reposition if needed to workaround a bug for Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4
if _current_session.window.size != defaults.WINDOW_SIZE:
_current_session.window.size = defaults.WINDOW_SIZE
if _current_session.window.position != defaults.WINDOW_POSITION:
_current_session.window.position = defaults.WINDOW_POSITION

# Set default timeouts
multiplier = configuration["timeout_multiplier"]
Expand Down Expand Up @@ -222,8 +226,12 @@ async def bidi_session(capabilities, configuration):

# Enforce a fixed default window size and position
if _current_session.capabilities.get("setWindowRect"):
_current_session.window.size = defaults.WINDOW_SIZE
_current_session.window.position = defaults.WINDOW_POSITION
# Only resize and reposition if needed to workaround a bug for Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4
if _current_session.window.size != defaults.WINDOW_SIZE:
_current_session.window.size = defaults.WINDOW_SIZE
if _current_session.window.position != defaults.WINDOW_POSITION:
_current_session.window.position = defaults.WINDOW_POSITION

yield _current_session.bidi_session

Expand Down
5 changes: 4 additions & 1 deletion webdriver/tests/support/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def _restore_window_state(session):
or fullscreened state.
"""
if session.capabilities.get("setWindowRect"):
session.window.size = defaults.WINDOW_SIZE
# Only resize if needed to workaround a bug for Chrome:
# https://bugs.chromium.org/p/chromedriver/issues/detail?id=4642#c4
if session.window.size != defaults.WINDOW_SIZE:
session.window.size = defaults.WINDOW_SIZE

@ignore_exceptions
def _restore_windows(session):
Expand Down

1 comment on commit dd03258

@community-tc-integration
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

HttpError: Invalid request.

Only 65535 characters are allowed; 5059508 were supplied.

Please sign in to comment.