Skip to content

[py] Skip bidi tests on browsers that don't support bidi #15625

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

Merged
merged 2 commits into from
Apr 15, 2025
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
5 changes: 5 additions & 0 deletions py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ def driver(request):
if "WebKit" in driver_class and _platform == "Windows":
pytest.skip("WebKit tests cannot be run on Windows")

# skip tests for drivers that don't support BiDi when --bidi is enabled
if request.config.option.bidi:
if driver_class in ("Ie", "Safari", "WebKitGTK", "WPEWebKit"):
pytest.skip(f"{driver_class} does not support BiDi")

# conditionally mark tests as expected to fail based on driver
marker = request.node.get_closest_marker(f"xfail_{driver_class.lower()}")

Expand Down
3 changes: 2 additions & 1 deletion py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ markers = [
"xfail_ie: Tests expected to fail in IE",
"xfail_remote: Tests expected to fail with Remote webdriver",
"xfail_safari: Tests expected to fail in Safari",
"xfail_webkitgtk: Tests expected to fail in webkitgtk",
"xfail_webkitgtk: Tests expected to fail in WebKitGTK",
"xfail_wpewebkit: Tests expected to fail in WPEWebKit",
"no_driver_after_test: If there are no drivers after the test it will create a new one."
]
python_files = ["test_*.py", "*_test.py", "*_tests.py"]
Expand Down
7 changes: 0 additions & 7 deletions py/test/selenium/webdriver/common/bidi_browser_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
from selenium.webdriver.common.bidi.browser import ClientWindowState


@pytest.mark.xfail_safari
def test_browser_initialized(driver):
"""Test that the browser module is initialized properly."""
assert driver.browser is not None


@pytest.mark.xfail_safari
def test_create_user_context(driver):
"""Test creating a user context."""
user_context = driver.browser.create_user_context()
Expand All @@ -37,7 +35,6 @@ def test_create_user_context(driver):
driver.browser.remove_user_context(user_context)


@pytest.mark.xfail_safari
def test_get_user_contexts(driver):
"""Test getting user contexts."""
user_context1 = driver.browser.create_user_context()
Expand All @@ -52,7 +49,6 @@ def test_get_user_contexts(driver):
driver.browser.remove_user_context(user_context2)


@pytest.mark.xfail_safari
def test_remove_user_context(driver):
"""Test removing a user context."""
user_context1 = driver.browser.create_user_context()
Expand All @@ -71,7 +67,6 @@ def test_remove_user_context(driver):
driver.browser.remove_user_context(user_context1)


@pytest.mark.xfail_safari
def test_get_client_windows(driver):
"""Test getting client windows."""
client_windows = driver.browser.get_client_windows()
Expand All @@ -91,13 +86,11 @@ def test_get_client_windows(driver):
assert window_info.get_y() >= 0


@pytest.mark.xfail_safari
def test_raises_exception_when_removing_default_user_context(driver):
with pytest.raises(Exception):
driver.browser.remove_user_context("default")


@pytest.mark.xfail_safari
def test_client_window_state_constants(driver):
assert ClientWindowState.FULLSCREEN == "fullscreen"
assert ClientWindowState.MAXIMIZED == "maximized"
Expand Down
8 changes: 0 additions & 8 deletions py/test/selenium/webdriver/common/bidi_network_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,21 @@
from selenium.webdriver.common.by import By


@pytest.mark.xfail_safari
def test_network_initialized(driver):
assert driver.network is not None


@pytest.mark.xfail_safari
def test_add_intercept(driver, pages):
result = driver.network._add_intercept()
assert result is not None, "Intercept not added"


@pytest.mark.xfail_safari
def test_remove_intercept(driver):
result = driver.network._add_intercept()
driver.network._remove_intercept(result["intercept"])
assert driver.network.intercepts == [], "Intercept not removed"


@pytest.mark.xfail_safari
def test_add_and_remove_request_handler(driver, pages):

requests = []
Expand All @@ -55,7 +51,6 @@ def callback(request: Request):
assert driver.find_element(By.NAME, "login").is_displayed(), "Request not continued"


@pytest.mark.xfail_safari
def test_clear_request_handlers(driver, pages):
requests = []

Expand All @@ -76,7 +71,6 @@ def callback(request: Request):

@pytest.mark.xfail_chrome
@pytest.mark.xfail_edge
@pytest.mark.xfail_safari
def test_continue_request(driver, pages):

def callback(request: Request):
Expand All @@ -90,7 +84,6 @@ def callback(request: Request):

@pytest.mark.xfail_chrome
@pytest.mark.xfail_edge
@pytest.mark.xfail_safari
def test_continue_with_auth(driver):

callback_id = driver.network.add_auth_handler("user", "passwd")
Expand All @@ -101,7 +94,6 @@ def test_continue_with_auth(driver):

@pytest.mark.xfail_chrome
@pytest.mark.xfail_edge
@pytest.mark.xfail_safari
def test_remove_auth_handler(driver):
callback_id = driver.network.add_auth_handler("user", "passwd")
assert callback_id is not None, "Request handler not added"
Expand Down
5 changes: 0 additions & 5 deletions py/test/selenium/webdriver/common/bidi_script_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,11 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import pytest

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait


@pytest.mark.xfail_safari
def test_logs_console_messages(driver, pages):
pages.load("bidi/logEntryAdded.html")

Expand All @@ -39,7 +37,6 @@ def test_logs_console_messages(driver, pages):
assert log_entry.type_ == "console"


@pytest.mark.xfail_safari
def test_logs_console_errors(driver, pages):
pages.load("bidi/logEntryAdded.html")
log_entries = []
Expand All @@ -64,7 +61,6 @@ def log_error(entry):
assert log_entry.type_ == "console"


@pytest.mark.xfail_safari
def test_logs_multiple_console_messages(driver, pages):
pages.load("bidi/logEntryAdded.html")

Expand All @@ -79,7 +75,6 @@ def test_logs_multiple_console_messages(driver, pages):
assert len(log_entries) == 2


@pytest.mark.xfail_safari
def test_removes_console_message_handler(driver, pages):
pages.load("bidi/logEntryAdded.html")

Expand Down
5 changes: 1 addition & 4 deletions py/test/selenium/webdriver/common/bidi_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

import pytest

from selenium.webdriver.common.by import By
Expand All @@ -23,7 +24,6 @@

@pytest.mark.xfail_firefox(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1819965")
@pytest.mark.xfail_remote(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1819965")
@pytest.mark.xfail_safari
async def test_check_console_messages(driver, pages):
async with driver.bidi_connection() as session:
log = Log(driver, session)
Expand All @@ -37,7 +37,6 @@ async def test_check_console_messages(driver, pages):

@pytest.mark.xfail_firefox(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1819965")
@pytest.mark.xfail_remote(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1819965")
@pytest.mark.xfail_safari
async def test_check_error_console_messages(driver, pages):
async with driver.bidi_connection() as session:
log = Log(driver, session)
Expand All @@ -51,7 +50,6 @@ async def test_check_error_console_messages(driver, pages):


@pytest.mark.xfail_firefox
@pytest.mark.xfail_safari
@pytest.mark.xfail_remote
async def test_collect_js_exceptions(driver, pages):
async with driver.bidi_connection() as session:
Expand All @@ -64,7 +62,6 @@ async def test_collect_js_exceptions(driver, pages):


@pytest.mark.xfail_firefox
@pytest.mark.xfail_safari
@pytest.mark.xfail_remote
async def test_collect_log_mutations(driver, pages):
async with driver.bidi_connection() as session:
Expand Down
Loading