From 2d59089c74a095c579985b37274f0f97a1cc25ec Mon Sep 17 00:00:00 2001 From: Lauro Moura Date: Sun, 8 Dec 2024 22:45:28 -0300 Subject: [PATCH] py: Fix WebKitGTK driver name. Similar to WPEWebKit changes from 24d88d73636e33, WebKitGTK does not follow the simple capitalization scheme for the driver name. This commit also changes the default `WebKitWebDriver` binary to the first one in `PATH` through shutil.which, instead of just the binary name. (Note: The effort to move to `pathlib` instead of `shutil`[1] is more related to shutil's functions that work on files and directories, like copy and move, instead of `which`, which just searches the executable paths for the given command.) [1] https://discuss.python.org/t/incrementally-move-high-level-path-operations-from-shutil-to-pathlib/19208 --- py/conftest.py | 3 ++- py/selenium/webdriver/webkitgtk/service.py | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/py/conftest.py b/py/conftest.py index d5bf9aca8c1ea..a16c83b3e0226 100644 --- a/py/conftest.py +++ b/py/conftest.py @@ -150,7 +150,8 @@ def fin(): options = get_options("Firefox", request.config) or webdriver.FirefoxOptions() options.set_capability("moz:firefoxOptions", {}) options.enable_downloads = True - if driver_class == "WebKitGTK": + if driver_class.lower() == "webkitgtk": + driver_class = "WebKitGTK" options = get_options(driver_class, request.config) if driver_class == "Edge": options = get_options(driver_class, request.config) diff --git a/py/selenium/webdriver/webkitgtk/service.py b/py/selenium/webdriver/webkitgtk/service.py index 7414556370bd0..defb3b3ae0684 100644 --- a/py/selenium/webdriver/webkitgtk/service.py +++ b/py/selenium/webdriver/webkitgtk/service.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 shutil import warnings from typing import List from typing import Mapping @@ -21,14 +22,14 @@ from selenium.webdriver.common import service -DEFAULT_EXECUTABLE_PATH: str = "WebKitWebDriver" +DEFAULT_EXECUTABLE_PATH: str = shutil.which("WebKitWebDriver") class Service(service.Service): """A Service class that is responsible for the starting and stopping of - `WPEWebDriver`. + `WebKitWebDriver`. - :param executable_path: install path of the WebKitWebDriver executable, defaults to `WebKitWebDriver`. + :param executable_path: install path of the WebKitWebDriver executable, defaults to the first `WebKitWebDriver` in `$PATH`. :param port: Port for the service to run on, defaults to 0 where the operating system will decide. :param service_args: (Optional) List of args to be passed to the subprocess when launching the executable. :param log_output: (Optional) File path for the file to be opened and passed as the subprocess stdout/stderr handler.