From 8ff5a11f7385d56463d1de3995dd08dbe1e6346e Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:08:03 -0400 Subject: [PATCH 1/6] [py] WIP - Support ARM binary selection for Selenium Manager --- py/selenium/webdriver/common/selenium_manager.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index 9caec37e10c7f..4e40a80e1fb48 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,19 @@ 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", "arm64"): "windows/selenium-manager-arm64.exe", + ("cygwin", "amd64"): "windows/selenium-manager.exe", + ("cygwin", "arm64"): "windows/selenium-manager-arm64.exe", ("linux", "x86_64"): "linux/selenium-manager", + ("linux", "arm64"): "linux/selenium-manager-arm64", ("freebsd", "x86_64"): "linux/selenium-manager", + ("freebsd", "arm64"): "linux/selenium-manager-arm64", ("openbsd", "x86_64"): "linux/selenium-manager", + ("openbsd", "arm64"): "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) From 39832012be4f0bb307cd4ff6022c85622a9000b7 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:19:12 -0400 Subject: [PATCH 2/6] [py] Update build files --- py/BUILD.bazel | 12 ++++++++++++ py/pyproject.toml | 2 ++ 2 files changed, 14 insertions(+) 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" ] From eb8e67386429bb93e6fedbae8390fdbe1be17b34 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:20:44 -0400 Subject: [PATCH 3/6] [py] Update tests and add aarch64 --- .../webdriver/common/selenium_manager.py | 3 ++ .../common/selenium_manager_tests.py | 30 ++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index 4e40a80e1fb48..0fb7d8a91a04a 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.py @@ -84,10 +84,13 @@ def _get_binary() -> Path: ("cygwin", "arm64"): "windows/selenium-manager-arm64.exe", ("linux", "x86_64"): "linux/selenium-manager", ("linux", "arm64"): "linux/selenium-manager-arm64", + ("linux", "aarch64"): "linux/selenium-manager-arm64", ("freebsd", "x86_64"): "linux/selenium-manager", ("freebsd", "arm64"): "linux/selenium-manager-arm64", + ("freebsd", "aarch64"): "linux/selenium-manager-arm64", ("openbsd", "x86_64"): "linux/selenium-manager", ("openbsd", "arm64"): "linux/selenium-manager-arm64", + ("openbsd", "aarch64"): "linux/selenium-manager-arm64", } arch = "any" if sys.platform == "darwin" else platform.machine().lower() diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 9195badf0ed21..49e1f1dc6594f 100644 --- a/py/test/selenium/webdriver/common/selenium_manager_tests.py +++ b/py/test/selenium/webdriver/common/selenium_manager_tests.py @@ -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(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): From 469f91b5d366b3b65c9bbdaf6b9fdc823e89072c Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:25:20 -0400 Subject: [PATCH 4/6] [py] Update supported architectures --- py/selenium/webdriver/common/selenium_manager.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index 0fb7d8a91a04a..e19623b4f6453 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.py @@ -79,15 +79,20 @@ def _get_binary() -> Path: allowed = { ("darwin", "any"): "macos/selenium-manager", ("win32", "amd64"): "windows/selenium-manager.exe", + ("win32", "x86_64"): "windows/selenium-manager.exe", ("win32", "arm64"): "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", + ("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", From 2674d49e8d4fc26f699848efd6bfed8b275d3a10 Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:32:56 -0400 Subject: [PATCH 5/6] [py] Add aarch64 for win32 --- py/selenium/webdriver/common/selenium_manager.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index e19623b4f6453..b4d85acee449d 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.py @@ -81,9 +81,11 @@ def _get_binary() -> Path: ("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", From cee55254669346dbf5f16c7ff2edf051326b4d2b Mon Sep 17 00:00:00 2001 From: Corey Goldberg <1113081+cgoldberg@users.noreply.github.com> Date: Mon, 14 Jul 2025 10:36:49 -0400 Subject: [PATCH 6/6] [py] Fix duplicate test name and remove unused import --- py/test/selenium/webdriver/common/selenium_manager_tests.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/py/test/selenium/webdriver/common/selenium_manager_tests.py b/py/test/selenium/webdriver/common/selenium_manager_tests.py index 49e1f1dc6594f..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 @@ -78,7 +78,7 @@ def test_uses_linux(monkeypatch): assert binary == project_root.joinpath("selenium/webdriver/common/linux/selenium-manager") -def test_uses_linux(monkeypatch): +def test_uses_linux_arm(monkeypatch): monkeypatch.setattr(sys, "platform", "linux") monkeypatch.setattr("platform.machine", lambda: "arm64")