diff --git a/py/BUILD.bazel b/py/BUILD.bazel index 37ace3ea3399c..d0fb7d3c0c918 100644 --- a/py/BUILD.bazel +++ b/py/BUILD.bazel @@ -100,6 +100,12 @@ copy_file( out = "selenium/webdriver/common/linux/selenium-manager", ) +copy_file( + name = "manager-linux-arm64", + src = "//common/manager:selenium-manager-linux-arm64", + out = "selenium/webdriver/common/linux/selenium-manager-arm64", +) + copy_file( name = "manager-macos", src = "//common/manager:selenium-manager-macos", @@ -112,6 +118,12 @@ copy_file( out = "selenium/webdriver/common/windows/selenium-manager.exe", ) +copy_file( + name = "manager-windows-arm64", + src = "//common/manager:selenium-manager-windows-arm64", + out = "selenium/webdriver/common/windows/selenium-manager-arm64.exe", +) + copy_file( name = "get-attribute", src = "//javascript/webdriver/atoms:get-attribute.js", diff --git a/py/pyproject.toml b/py/pyproject.toml index 948d5a5a49857..08ffc68b36a1c 100644 --- a/py/pyproject.toml +++ b/py/pyproject.toml @@ -64,7 +64,9 @@ target = "selenium.webdriver.common.selenium-manager" "prune*", "selenium.egg-info*", "selenium-manager", + "selenium-manager-arm64", "selenium-manager.exe", + "selenium-manager-arm64.exe", "CHANGES", "LICENSE" ] diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index 9caec37e10c7f..b4d85acee449d 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.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 logging import os @@ -77,14 +78,29 @@ def _get_binary() -> Path: else: allowed = { ("darwin", "any"): "macos/selenium-manager", - ("win32", "any"): "windows/selenium-manager.exe", - ("cygwin", "any"): "windows/selenium-manager.exe", + ("win32", "amd64"): "windows/selenium-manager.exe", + ("win32", "x86_64"): "windows/selenium-manager.exe", + ("win32", "arm64"): "windows/selenium-manager-arm64.exe", + ("win32", "aarch64"): "windows/selenium-manager-arm64.exe", + ("cygwin", "amd64"): "windows/selenium-manager.exe", + ("cygwin", "x86_64"): "windows/selenium-manager.exe", + ("cygwin", "arm64"): "windows/selenium-manager-arm64.exe", + ("cygwin", "aarch64"): "windows/selenium-manager-arm64.exe", + ("linux", "amd64"): "linux/selenium-manager", ("linux", "x86_64"): "linux/selenium-manager", + ("linux", "arm64"): "linux/selenium-manager-arm64", + ("linux", "aarch64"): "linux/selenium-manager-arm64", + ("freebsd", "amd64"): "linux/selenium-manager", ("freebsd", "x86_64"): "linux/selenium-manager", + ("freebsd", "arm64"): "linux/selenium-manager-arm64", + ("freebsd", "aarch64"): "linux/selenium-manager-arm64", + ("openbsd", "amd64"): "linux/selenium-manager", ("openbsd", "x86_64"): "linux/selenium-manager", + ("openbsd", "arm64"): "linux/selenium-manager-arm64", + ("openbsd", "aarch64"): "linux/selenium-manager-arm64", } - arch = platform.machine() if sys.platform in ("linux", "freebsd", "openbsd") else "any" + arch = "any" if sys.platform == "darwin" else platform.machine().lower() if sys.platform in ["freebsd", "openbsd"]: logger.warning("Selenium Manager binary may not be compatible with %s; verify settings", sys.platform) diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 9195badf0ed21..1bc0aec9b8731 100644 --- a/py/test/selenium/webdriver/common/selenium_manager_tests.py +++ b/py/test/selenium/webdriver/common/selenium_manager_tests.py @@ -14,8 +14,8 @@ # 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 from pathlib import Path from unittest import mock @@ -53,22 +53,38 @@ def test_uses_environment_variable(monkeypatch): def test_uses_windows(monkeypatch): monkeypatch.setattr(sys, "platform", "win32") + monkeypatch.setattr("platform.machine", lambda: "AMD64") binary = SeleniumManager()._get_binary() project_root = Path(selenium.__file__).parent.parent assert binary == project_root.joinpath("selenium/webdriver/common/windows/selenium-manager.exe") +def test_uses_windows_arm(monkeypatch): + monkeypatch.setattr(sys, "platform", "win32") + monkeypatch.setattr("platform.machine", lambda: "arm64") + binary = SeleniumManager()._get_binary() + + project_root = Path(selenium.__file__).parent.parent + assert binary == project_root.joinpath("selenium/webdriver/common/windows/selenium-manager-arm64.exe") + + def test_uses_linux(monkeypatch): monkeypatch.setattr(sys, "platform", "linux") + monkeypatch.setattr("platform.machine", lambda: "x86_64") - 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") + 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_arm(monkeypatch): + monkeypatch.setattr(sys, "platform", "linux") + monkeypatch.setattr("platform.machine", lambda: "arm64") + + binary = SeleniumManager()._get_binary() + project_root = Path(selenium.__file__).parent.parent + assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager-arm64") def test_uses_mac(monkeypatch):