Skip to content

Commit 3f9c5cb

Browse files
authored
[py] Fix Selenium Manager tests on Windows (#16391)
* [py] Fix Selenium Manager tests on Windows * [py] Remove Windows tests from CI workflows * [py] Combine bazel commands to prevent false passes
1 parent 04a927e commit 3f9c5cb

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed

.github/workflows/bazel.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ jobs:
126126
with:
127127
bazelisk-cache: true
128128
bazelrc: common --color=yes
129+
# Workaround for long path issues: https://github.com/bazelbuild/bazel/pull/22532
130+
output-base: ${{ inputs.os == 'windows' && 'D://b' || '' }}
129131
cache-version: 2
130132
disk-cache: ${{ inputs.cache-key }}
131133
external-cache: |

.github/workflows/ci-python.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,13 @@ jobs:
9999
os: ubuntu
100100
- browser: firefox
101101
os: ubuntu
102-
- browser: chrome
103-
os: windows
104-
- browser: edge
105-
os: windows
106102
with:
107103
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
108104
browser: ${{ matrix.browser }}
109105
os: ${{ matrix.os }}
110106
cache-key: py-browser-${{ matrix.browser }}
111107
run: |
112-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi
113-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }}
108+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }}
114109
115110
safari-tests:
116111
name: Browser Tests
@@ -128,5 +123,4 @@ jobs:
128123
os: ${{ matrix.os }}
129124
cache-key: py-browser-${{ matrix.browser }}
130125
run: |
131-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}
132-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }}
126+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }} //py:test-${{ matrix.browser }}

py/test/selenium/webdriver/common/selenium_manager_tests.py

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
1718
import json
18-
import platform
1919
import sys
2020
from pathlib import Path
2121
from unittest import mock
@@ -43,12 +43,13 @@ def test_gets_results(monkeypatch):
4343

4444

4545
def test_uses_environment_variable(monkeypatch):
46-
monkeypatch.setenv("SE_MANAGER_PATH", "/path/to/manager")
46+
sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager"
47+
monkeypatch.setenv("SE_MANAGER_PATH", sm_path)
4748
monkeypatch.setattr(Path, "is_file", lambda _: True)
4849

4950
binary = SeleniumManager()._get_binary()
5051

51-
assert str(binary) == "/path/to/manager"
52+
assert str(binary) == sm_path
5253

5354

5455
def test_uses_windows(monkeypatch):
@@ -61,14 +62,19 @@ def test_uses_windows(monkeypatch):
6162

6263
def test_uses_linux(monkeypatch):
6364
monkeypatch.setattr(sys, "platform", "linux")
65+
monkeypatch.setattr("platform.machine", lambda: "x86_64")
66+
67+
binary = SeleniumManager()._get_binary()
68+
project_root = Path(selenium.__file__).parent.parent
69+
assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager")
70+
71+
72+
def test_uses_linux_arm64(monkeypatch):
73+
monkeypatch.setattr(sys, "platform", "linux")
74+
monkeypatch.setattr("platform.machine", lambda: "arm64")
6475

65-
if platform.machine() == "arm64":
66-
with pytest.raises(WebDriverException, match="Unsupported platform/architecture combination: linux/arm64"):
67-
SeleniumManager()._get_binary()
68-
else:
69-
binary = SeleniumManager()._get_binary()
70-
project_root = Path(selenium.__file__).parent.parent
71-
assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager")
76+
with pytest.raises(WebDriverException, match="Unsupported platform/architecture combination: linux/arm64"):
77+
SeleniumManager()._get_binary()
7278

7379

7480
def test_uses_mac(monkeypatch):
@@ -97,11 +103,12 @@ def test_errors_if_invalid_os(monkeypatch):
97103

98104

99105
def test_error_if_invalid_env_path(monkeypatch):
100-
monkeypatch.setenv("SE_MANAGER_PATH", "/path/to/manager")
106+
sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager"
107+
monkeypatch.setenv("SE_MANAGER_PATH", sm_path)
101108

102109
with pytest.raises(WebDriverException) as excinfo:
103110
SeleniumManager()._get_binary()
104-
assert "Unable to obtain working Selenium Manager binary; /path/to/manager" in str(excinfo.value)
111+
assert f"Unable to obtain working Selenium Manager binary; {sm_path}" in str(excinfo.value)
105112

106113

107114
def test_run_successful():

0 commit comments

Comments
 (0)