Skip to content

Commit 2679906

Browse files
committed
[py] Fix Selenium Manager tests on Windows
1 parent 3b61afe commit 2679906

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

.github/workflows/ci-python.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,6 @@ 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 }}

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

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
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
1819
import platform
1920
import sys
@@ -43,12 +44,13 @@ def test_gets_results(monkeypatch):
4344

4445

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

4951
binary = SeleniumManager()._get_binary()
5052

51-
assert str(binary) == "/path/to/manager"
53+
assert str(binary) == sm_path
5254

5355

5456
def test_uses_windows(monkeypatch):
@@ -59,16 +61,22 @@ def test_uses_windows(monkeypatch):
5961
assert binary == project_root.joinpath("selenium/webdriver/common/windows/selenium-manager.exe")
6062

6163

64+
6265
def test_uses_linux(monkeypatch):
6366
monkeypatch.setattr(sys, "platform", "linux")
67+
monkeypatch.setattr("platform.machine", lambda: "x86_64")
68+
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")
6472

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")
73+
74+
def test_uses_linux_arm64(monkeypatch):
75+
monkeypatch.setattr(sys, "platform", "linux")
76+
monkeypatch.setattr("platform.machine", lambda: "arm64")
77+
78+
with pytest.raises(WebDriverException, match="Unsupported platform/architecture combination: linux/arm64"):
79+
SeleniumManager()._get_binary()
7280

7381

7482
def test_uses_mac(monkeypatch):
@@ -97,11 +105,12 @@ def test_errors_if_invalid_os(monkeypatch):
97105

98106

99107
def test_error_if_invalid_env_path(monkeypatch):
100-
monkeypatch.setenv("SE_MANAGER_PATH", "/path/to/manager")
108+
sm_path = r"\path\to\manager" if sys.platform.startswith("win") else "path/to/manager"
109+
monkeypatch.setenv("SE_MANAGER_PATH", sm_path)
101110

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

106115

107116
def test_run_successful():

0 commit comments

Comments
 (0)