Skip to content

Commit 8ea4318

Browse files
[py] Correct usage of Executable Path in Service
1 parent 53874e6 commit 8ea4318

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

py/selenium/webdriver/chromium/service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self.log_output = log_output
5050

5151
super().__init__(
52-
executable=executable_path,
52+
executable_path=executable_path,
5353
port=port,
5454
env=env,
5555
log_output=self.log_output,

py/selenium/webdriver/common/driver_finder.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def get_path(service: Service, options: BaseOptions) -> str:
4141
raise NoSuchDriverException(msg) from err
4242

4343
if path is None or not Path(path).is_file():
44-
raise NoSuchDriverException(f"Unable to locate or obtain driver for {options.capabilities['browserName']}")
44+
raise NoSuchDriverException(
45+
f"Unable to locate or obtain driver for {options.capabilities['browserName']}"
46+
)
4547

4648
return path

py/selenium/webdriver/common/service.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Service(ABC):
4848

4949
def __init__(
5050
self,
51-
executable: str = None,
51+
executable_path: str = None,
5252
port: int = 0,
5353
log_output: SubprocessStdAlias = None,
5454
env: typing.Optional[typing.Mapping[typing.Any, typing.Any]] = None,
@@ -63,7 +63,7 @@ def __init__(
6363
else:
6464
self.log_output = log_output
6565

66-
self._path = executable
66+
self._path = executable_path
6767
self.port = port or utils.free_port()
6868
# Default value for every python subprocess: subprocess.Popen(..., creationflags=0)
6969
self.popen_kw = kwargs.pop("popen_kw", {})
@@ -112,7 +112,9 @@ def assert_process_still_running(self) -> None:
112112
"""Check if the underlying process is still running."""
113113
return_code = self.process.poll()
114114
if return_code:
115-
raise WebDriverException(f"Service {self._path} unexpectedly exited. Status code was: {return_code}")
115+
raise WebDriverException(
116+
f"Service {self._path} unexpectedly exited. Status code was: {return_code}"
117+
)
116118

117119
def is_connectable(self) -> bool:
118120
"""Establishes a socket connection to determine if the service running
@@ -157,7 +159,11 @@ def _terminate_process(self) -> None:
157159
silently ignores errors here.
158160
"""
159161
try:
160-
stdin, stdout, stderr = self.process.stdin, self.process.stdout, self.process.stderr
162+
stdin, stdout, stderr = (
163+
self.process.stdin,
164+
self.process.stdout,
165+
self.process.stderr,
166+
)
161167
for stream in stdin, stdout, stderr:
162168
try:
163169
stream.close() # type: ignore
@@ -198,7 +204,9 @@ def _start_process(self, path: str) -> None:
198204
start_info = None
199205
if system() == "Windows":
200206
start_info = subprocess.STARTUPINFO()
201-
start_info.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
207+
start_info.dwFlags = (
208+
subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
209+
)
202210
start_info.wShowWindow = subprocess.SW_HIDE
203211

204212
self.process = subprocess.Popen(

0 commit comments

Comments
 (0)