Skip to content

Commit

Permalink
py: Fix WebKitGTK driver name.
Browse files Browse the repository at this point in the history
Similar to WPEWebKit changes from 24d88d7, 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
  • Loading branch information
lauromoura committed Jan 8, 2025
1 parent 8ae9c3b commit 2d59089
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion py/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions py/selenium/webdriver/webkitgtk/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,22 @@
# 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
from typing import Optional

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.
Expand Down

0 comments on commit 2d59089

Please sign in to comment.