From 26799068aacef0e6411c38ec760b755ad5d308e5 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 15:20:53 -0400 Subject: [PATCH 1/6] [py] Fix Selenium Manager tests on Windows --- .github/workflows/ci-python.yml | 4 --- .../common/selenium_manager_tests.py | 31 ++++++++++++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 96c5182b71740..81a1015660c58 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -99,10 +99,6 @@ jobs: os: ubuntu - browser: firefox os: ubuntu - - browser: chrome - os: windows - - browser: edge - os: windows with: name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 9195badf0ed21..107b925b14620 100644 --- a/py/test/selenium/webdriver/common/selenium_manager_tests.py +++ b/py/test/selenium/webdriver/common/selenium_manager_tests.py @@ -14,6 +14,7 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. + import json import platform import sys @@ -43,12 +44,13 @@ def test_gets_results(monkeypatch): def test_uses_environment_variable(monkeypatch): - monkeypatch.setenv("SE_MANAGER_PATH", "/path/to/manager") + sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" + monkeypatch.setenv("SE_MANAGER_PATH", sm_path) monkeypatch.setattr(Path, "is_file", lambda _: True) binary = SeleniumManager()._get_binary() - assert str(binary) == "/path/to/manager" + assert str(binary) == sm_path def test_uses_windows(monkeypatch): @@ -59,16 +61,22 @@ def test_uses_windows(monkeypatch): assert binary == project_root.joinpath("selenium/webdriver/common/windows/selenium-manager.exe") + def test_uses_linux(monkeypatch): monkeypatch.setattr(sys, "platform", "linux") + monkeypatch.setattr("platform.machine", lambda: "x86_64") + + 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_linux_arm64(monkeypatch): + monkeypatch.setattr(sys, "platform", "linux") + monkeypatch.setattr("platform.machine", lambda: "arm64") + + with pytest.raises(WebDriverException, match="Unsupported platform/architecture combination: linux/arm64"): + SeleniumManager()._get_binary() def test_uses_mac(monkeypatch): @@ -97,11 +105,12 @@ def test_errors_if_invalid_os(monkeypatch): def test_error_if_invalid_env_path(monkeypatch): - monkeypatch.setenv("SE_MANAGER_PATH", "/path/to/manager") + sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" + monkeypatch.setenv("SE_MANAGER_PATH", sm_path) with pytest.raises(WebDriverException) as excinfo: SeleniumManager()._get_binary() - assert "Unable to obtain working Selenium Manager binary; /path/to/manager" in str(excinfo.value) + assert f"Unable to obtain working Selenium Manager binary; {sm_path}" in str(excinfo.value) def test_run_successful(): From aa52261242c1ceadbb6404468cb298c766effdd0 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 15:50:22 -0400 Subject: [PATCH 2/6] [py] Workaround for Bazel long path issue --- .github/workflows/bazel.yml | 2 ++ .github/workflows/ci-python.yml | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 017ab6fa92eea..5b5911c33de62 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -126,6 +126,8 @@ jobs: with: bazelisk-cache: true bazelrc: common --color=yes + # Workaround for long path issues: https://github.com/bazelbuild/bazel/pull/22532 + output-base: ${{ inputs.os == 'windows' && 'D://b || '' }} cache-version: 2 disk-cache: ${{ inputs.cache-key }} external-cache: | diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 81a1015660c58..53ee93bf682ea 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -64,6 +64,7 @@ jobs: include: - os: ubuntu - os: macos + - os: windows with: name: Unit Tests (${{ matrix.os }}) os: ${{ matrix.os }} @@ -99,6 +100,10 @@ jobs: os: ubuntu - browser: firefox os: ubuntu + - browser: chrome + os: windows + - browser: edge + os: windows with: name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} From 02f3143cf59d47e3cae9c9e52cd6471559616e40 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 15:56:32 -0400 Subject: [PATCH 3/6] [py] Fix broken workflow --- .github/workflows/bazel.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bazel.yml b/.github/workflows/bazel.yml index 5b5911c33de62..2c0a7811ef875 100644 --- a/.github/workflows/bazel.yml +++ b/.github/workflows/bazel.yml @@ -127,7 +127,7 @@ jobs: bazelisk-cache: true bazelrc: common --color=yes # Workaround for long path issues: https://github.com/bazelbuild/bazel/pull/22532 - output-base: ${{ inputs.os == 'windows' && 'D://b || '' }} + output-base: ${{ inputs.os == 'windows' && 'D://b' || '' }} cache-version: 2 disk-cache: ${{ inputs.cache-key }} external-cache: | From ebff5c568e95326e0d13943836c747cf56c80b28 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 16:10:46 -0400 Subject: [PATCH 4/6] [py] Fix formatting --- py/test/selenium/webdriver/common/selenium_manager_tests.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 107b925b14620..5a70faab1e499 100644 --- a/py/test/selenium/webdriver/common/selenium_manager_tests.py +++ b/py/test/selenium/webdriver/common/selenium_manager_tests.py @@ -16,7 +16,6 @@ # under the License. import json -import platform import sys from pathlib import Path from unittest import mock @@ -44,7 +43,7 @@ def test_gets_results(monkeypatch): def test_uses_environment_variable(monkeypatch): - sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" + sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" monkeypatch.setenv("SE_MANAGER_PATH", sm_path) monkeypatch.setattr(Path, "is_file", lambda _: True) @@ -61,7 +60,6 @@ def test_uses_windows(monkeypatch): assert binary == project_root.joinpath("selenium/webdriver/common/windows/selenium-manager.exe") - def test_uses_linux(monkeypatch): monkeypatch.setattr(sys, "platform", "linux") monkeypatch.setattr("platform.machine", lambda: "x86_64") @@ -105,7 +103,7 @@ def test_errors_if_invalid_os(monkeypatch): def test_error_if_invalid_env_path(monkeypatch): - sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" + sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager" monkeypatch.setenv("SE_MANAGER_PATH", sm_path) with pytest.raises(WebDriverException) as excinfo: From bf6a7ebfd12052da5e423ff9b00853b23a1284c1 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 18:20:01 -0400 Subject: [PATCH 5/6] [py] Remove Windows from workflows and combine bazel commands --- .github/workflows/ci-python.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 53ee93bf682ea..51e49066e08d6 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -64,7 +64,6 @@ jobs: include: - os: ubuntu - os: macos - - os: windows with: name: Unit Tests (${{ matrix.os }}) os: ${{ matrix.os }} @@ -100,19 +99,13 @@ jobs: os: ubuntu - browser: firefox os: ubuntu - - browser: chrome - os: windows - - browser: edge - os: windows with: name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }}) browser: ${{ matrix.browser }} os: ${{ matrix.os }} cache-key: py-browser-${{ matrix.browser }} run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi - bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }} - + bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }} safari-tests: name: Browser Tests needs: build @@ -129,5 +122,4 @@ jobs: os: ${{ matrix.os }} cache-key: py-browser-${{ matrix.browser }} run: | - bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }} - bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }} + bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }} //py:test-${{ matrix.browser }} From 18be6359c9edf21c24d83d22663c2adadb0e2f03 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 6 Oct 2025 18:34:58 -0400 Subject: [PATCH 6/6] [py] Add missing newline --- .github/workflows/ci-python.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-python.yml b/.github/workflows/ci-python.yml index 51e49066e08d6..8cbff243e0962 100644 --- a/.github/workflows/ci-python.yml +++ b/.github/workflows/ci-python.yml @@ -106,6 +106,7 @@ jobs: cache-key: py-browser-${{ matrix.browser }} run: | bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }} + safari-tests: name: Browser Tests needs: build