Skip to content

Commit 70dfc27

Browse files
lauromourayvsvarma
authored andcommitted
[py] Fix WebKitGTK driver name check (#15046)
py: Fix WebKitGTK driver name. 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
1 parent 8a97898 commit 70dfc27

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

py/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def fin():
150150
options = get_options("Firefox", request.config) or webdriver.FirefoxOptions()
151151
options.set_capability("moz:firefoxOptions", {})
152152
options.enable_downloads = True
153-
if driver_class == "WebKitGTK":
153+
if driver_class.lower() == "webkitgtk":
154+
driver_class = "WebKitGTK"
154155
options = get_options(driver_class, request.config)
155156
if driver_class == "Edge":
156157
options = get_options(driver_class, request.config)

py/selenium/webdriver/webkitgtk/service.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@
1414
# KIND, either express or implied. See the License for the
1515
# specific language governing permissions and limitations
1616
# under the License.
17+
import shutil
1718
import warnings
1819
from typing import List
1920
from typing import Mapping
2021
from typing import Optional
2122

2223
from selenium.webdriver.common import service
2324

24-
DEFAULT_EXECUTABLE_PATH: str = "WebKitWebDriver"
25+
DEFAULT_EXECUTABLE_PATH: str = shutil.which("WebKitWebDriver")
2526

2627

2728
class Service(service.Service):
2829
"""A Service class that is responsible for the starting and stopping of
29-
`WPEWebDriver`.
30+
`WebKitWebDriver`.
3031
31-
:param executable_path: install path of the WebKitWebDriver executable, defaults to `WebKitWebDriver`.
32+
:param executable_path: install path of the WebKitWebDriver executable, defaults to the first `WebKitWebDriver` in `$PATH`.
3233
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
3334
:param service_args: (Optional) List of args to be passed to the subprocess when launching the executable.
3435
:param log_output: (Optional) File path for the file to be opened and passed as the subprocess stdout/stderr handler.

0 commit comments

Comments
 (0)