diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index cebe68597d063..e826cab4a91f0 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -96,5 +96,4 @@ jobs: browser: safari os: macos cache-key: py-safari - run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-safari-test/selenium/webdriver/safari/launcher_tests.py + run: bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-safari diff --git a/py/test/selenium/webdriver/common/alerts_tests.py b/py/test/selenium/webdriver/common/alerts_tests.py index ea37e0e3d5371..9479df88fadf5 100644 --- a/py/test/selenium/webdriver/common/alerts_tests.py +++ b/py/test/selenium/webdriver/common/alerts_tests.py @@ -294,6 +294,7 @@ def test_alert_should_not_allow_additional_commands_if_dismissed(driver, pages): @pytest.mark.xfail_remote(reason="https://bugzilla.mozilla.org/show_bug.cgi?id=1279211") @pytest.mark.xfail_chrome @pytest.mark.xfail_edge +@pytest.mark.xfail_safari def test_unexpected_alert_present_exception_contains_alert_text(driver, pages): pages.load("alerts.html") driver.find_element(by=By.ID, value="alert").click() diff --git a/py/test/selenium/webdriver/common/api_example_tests.py b/py/test/selenium/webdriver/common/api_example_tests.py index 7b8a4cedee3d8..40b3d2b7a2f01 100644 --- a/py/test/selenium/webdriver/common/api_example_tests.py +++ b/py/test/selenium/webdriver/common/api_example_tests.py @@ -240,6 +240,7 @@ def test_is_element_displayed(driver, pages): @pytest.mark.xfail_chrome +@pytest.mark.xfail_safari def test_move_window_position(driver, pages): pages.load("blank.html") loc = driver.get_window_position() diff --git a/py/test/selenium/webdriver/common/interactions_tests.py b/py/test/selenium/webdriver/common/interactions_tests.py index 8c2ad03fc8d6f..7ffe0e9dc4e0b 100644 --- a/py/test/selenium/webdriver/common/interactions_tests.py +++ b/py/test/selenium/webdriver/common/interactions_tests.py @@ -253,6 +253,7 @@ def test_can_pause(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_to_element(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") iframe = driver.find_element(By.TAG_NAME, "iframe") @@ -266,6 +267,7 @@ def test_can_scroll_to_element(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_from_element_by_amount(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") iframe = driver.find_element(By.TAG_NAME, "iframe") @@ -280,6 +282,7 @@ def test_can_scroll_from_element_by_amount(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_from_element_with_offset_by_amount(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") footer = driver.find_element(By.TAG_NAME, "footer") @@ -314,6 +317,7 @@ def test_can_scroll_from_viewport_by_amount(driver, pages): assert _in_viewport(driver, footer) +@pytest.mark.xfail_safari def test_can_scroll_from_viewport_with_offset_by_amount(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame.html") scroll_origin = ScrollOrigin.from_viewport(10, 10) diff --git a/py/test/selenium/webdriver/common/interactions_with_device_tests.py b/py/test/selenium/webdriver/common/interactions_with_device_tests.py index 926b93c641e44..f82f3967a0776 100644 --- a/py/test/selenium/webdriver/common/interactions_with_device_tests.py +++ b/py/test/selenium/webdriver/common/interactions_with_device_tests.py @@ -247,6 +247,7 @@ def test_can_pause_with_pointer(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_to_element_with_wheel(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") iframe = driver.find_element(By.TAG_NAME, "iframe") @@ -262,6 +263,7 @@ def test_can_scroll_to_element_with_wheel(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_from_element_by_amount_with_wheel(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") iframe = driver.find_element(By.TAG_NAME, "iframe") @@ -278,6 +280,7 @@ def test_can_scroll_from_element_by_amount_with_wheel(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_can_scroll_from_element_with_offset_by_amount_with_wheel(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame_out_of_view.html") footer = driver.find_element(By.TAG_NAME, "footer") @@ -320,6 +323,7 @@ def test_can_scroll_from_viewport_by_amount_with_wheel(driver, pages): @pytest.mark.xfail_firefox +@pytest.mark.xfail_safari def test_can_scroll_from_viewport_with_offset_by_amount_with_wheel(driver, pages): pages.load("scrolling_tests/frame_with_nested_scrolling_frame.html") scroll_origin = ScrollOrigin.from_viewport(10, 10) diff --git a/py/test/selenium/webdriver/common/position_and_size_tests.py b/py/test/selenium/webdriver/common/position_and_size_tests.py index a438c0f5e0c88..081c51358a517 100644 --- a/py/test/selenium/webdriver/common/position_and_size_tests.py +++ b/py/test/selenium/webdriver/common/position_and_size_tests.py @@ -53,6 +53,7 @@ def test_should_get_coordinates_of_an_invisible_element(driver, pages): _check_location(element.location, x=0, y=0) +@pytest.mark.xfail_safari def test_should_scroll_page_and_get_coordinates_of_an_element_that_is_out_of_view_port(driver, pages): pages.load("coordinates_tests/page_with_element_out_of_view.html") element = driver.find_element(By.ID, "box") @@ -89,6 +90,7 @@ def test_should_get_coordinates_of_an_element_in_anested_frame(driver, pages): _check_location(element.location, x=10, y=10) +@pytest.mark.xfail_safari def test_should_get_coordinates_of_an_element_with_fixed_position(driver, pages): pages.load("coordinates_tests/page_with_fixed_element.html") element = driver.find_element(By.ID, "fixed") diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 8692644cee0c4..67239bf87a67d 100644 --- a/py/test/selenium/webdriver/common/selenium_manager_tests.py +++ b/py/test/selenium/webdriver/common/selenium_manager_tests.py @@ -15,6 +15,7 @@ # specific language governing permissions and limitations # under the License. import json +import platform import sys from pathlib import Path from unittest import mock @@ -59,10 +60,14 @@ def test_uses_windows(monkeypatch): def test_uses_linux(monkeypatch): monkeypatch.setattr(sys, "platform", "linux") - binary = SeleniumManager()._get_binary() - project_root = Path(selenium.__file__).parent.parent - assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager") + if platform.machine() == "arm64": + with pytest.raises(WebDriverException, match="Unsupported platform/architecture combination: linux/arm64"): + SeleniumManager()._get_binary() + else: + binary = SeleniumManager()._get_binary() + project_root = Path(selenium.__file__).parent.parent + assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager") def test_uses_mac(monkeypatch): diff --git a/py/test/selenium/webdriver/common/upload_tests.py b/py/test/selenium/webdriver/common/upload_tests.py index df2906eecce74..642085790e303 100644 --- a/py/test/selenium/webdriver/common/upload_tests.py +++ b/py/test/selenium/webdriver/common/upload_tests.py @@ -16,6 +16,7 @@ # under the License. import os +import textwrap import pytest @@ -30,11 +31,13 @@ def get_local_path(): current_dir = os.path.dirname(os.path.realpath(__file__)) def wrapped(filename): - return os.path.join(current_dir, filename) + full_path = os.path.join(current_dir, filename) + return textwrap.fill(full_path, width=512) return wrapped +@pytest.mark.xfail_safari def test_can_upload_file(driver, pages, get_local_path): pages.load("upload.html") @@ -45,6 +48,7 @@ def test_can_upload_file(driver, pages, get_local_path): WebDriverWait(driver, 10).until(EC.text_to_be_present_in_element((By.CSS_SELECTOR, "body"), "test_file.txt")) +@pytest.mark.xfail_safari def test_can_upload_two_files(driver, pages, get_local_path): pages.load("upload.html") two_file_paths = get_local_path("test_file.txt") + "\n" + get_local_path("test_file2.txt") diff --git a/py/test/selenium/webdriver/common/w3c_interaction_tests.py b/py/test/selenium/webdriver/common/w3c_interaction_tests.py index d0a00ac26a2d4..5376265ede3bb 100644 --- a/py/test/selenium/webdriver/common/w3c_interaction_tests.py +++ b/py/test/selenium/webdriver/common/w3c_interaction_tests.py @@ -176,6 +176,7 @@ def test_dragging_element_with_mouse_fires_events(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_pen_pointer_properties(driver, pages): pages.load("pointerActionsPage.html") @@ -223,6 +224,7 @@ def test_pen_pointer_properties(driver, pages): @pytest.mark.xfail_firefox @pytest.mark.xfail_remote +@pytest.mark.xfail_safari def test_touch_pointer_properties(driver, pages): pages.load("pointerActionsPage.html") pointerArea = driver.find_element(By.CSS_SELECTOR, "#pointerArea") diff --git a/py/test/selenium/webdriver/common/webdriverwait_tests.py b/py/test/selenium/webdriver/common/webdriverwait_tests.py index 14019d185e8b0..f332933e4241c 100644 --- a/py/test/selenium/webdriver/common/webdriverwait_tests.py +++ b/py/test/selenium/webdriver/common/webdriverwait_tests.py @@ -35,6 +35,7 @@ def throw_sere(driver): @pytest.mark.xfail_chrome(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743") @pytest.mark.xfail_edge(reason="https://bugs.chromium.org/p/chromedriver/issues/detail?id=4743") +@pytest.mark.xfail_safari def test_should_fail_with_invalid_selector_exception(driver, pages): pages.load("dynamic.html") with pytest.raises(InvalidSelectorException): diff --git a/py/test/selenium/webdriver/common/window_switching_tests.py b/py/test/selenium/webdriver/common/window_switching_tests.py index 1e2359cd52b36..2883ab2c55f69 100644 --- a/py/test/selenium/webdriver/common/window_switching_tests.py +++ b/py/test/selenium/webdriver/common/window_switching_tests.py @@ -130,6 +130,7 @@ def test_should_throw_no_such_window_exception_on_any_element_operation_if_awind element.text +@pytest.mark.xfail_safari def test_clicking_on_abutton_that_closes_an_open_window_does_not_cause_the_browser_to_hang(driver, pages): pages.load("xhtmlTest.html") current = driver.current_window_handle diff --git a/py/test/selenium/webdriver/safari/__init__.py b/py/test/selenium/webdriver/safari/__init__.py new file mode 100644 index 0000000000000..a5b1e6f85a09e --- /dev/null +++ b/py/test/selenium/webdriver/safari/__init__.py @@ -0,0 +1,16 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. diff --git a/py/test/selenium/webdriver/safari/safari_service_tests.py b/py/test/selenium/webdriver/safari/safari_service_tests.py new file mode 100644 index 0000000000000..494cbe6be6143 --- /dev/null +++ b/py/test/selenium/webdriver/safari/safari_service_tests.py @@ -0,0 +1,59 @@ +# Licensed to the Software Freedom Conservancy (SFC) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The SFC licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import os + +import pytest + +from selenium.webdriver.safari.service import Service + + +@pytest.fixture +def service(): + return Service() + + +@pytest.mark.usefixtures("service") +class TestSafariDriverService: + service_path = "/path/to/safaridriver" + + @pytest.fixture(autouse=True) + def setup_and_teardown(self): + os.environ["SE_SAFARIDRIVER"] = self.service_path + yield + os.environ.pop("SE_SAFARIDRIVER", None) + + def test_uses_path_from_env_variable(self, service): + assert "safaridriver" in service.path + + def test_updates_path_after_setting_env_variable(self, service): + new_path = "/foo/bar" + os.environ["SE_SAFARIDRIVER"] = new_path + service.executable_path = self.service_path # Simulating the update + + assert "safaridriver" in service.executable_path + + +def test_enable_logging(): + enable_logging = True + service = Service(enable_logging=enable_logging) + assert "--diagnose" in service.service_args + + +def test_service_url(): + service = Service(port=1313) + assert service.service_url == "http://localhost:1313"