Skip to content

Commit

Permalink
[py] Correct usage of Executable Path in Service
Browse files Browse the repository at this point in the history
  • Loading branch information
AutomatedTester committed Nov 10, 2023
1 parent 53874e6 commit 8ea4318
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion py/selenium/webdriver/chromium/service.py
Expand Up @@ -49,7 +49,7 @@ def __init__(
self.log_output = log_output

super().__init__(
executable=executable_path,
executable_path=executable_path,
port=port,
env=env,
log_output=self.log_output,
Expand Down
4 changes: 3 additions & 1 deletion py/selenium/webdriver/common/driver_finder.py
Expand Up @@ -41,6 +41,8 @@ def get_path(service: Service, options: BaseOptions) -> str:
raise NoSuchDriverException(msg) from err

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

return path
18 changes: 13 additions & 5 deletions py/selenium/webdriver/common/service.py
Expand Up @@ -48,7 +48,7 @@ class Service(ABC):

def __init__(
self,
executable: str = None,
executable_path: str = None,
port: int = 0,
log_output: SubprocessStdAlias = None,
env: typing.Optional[typing.Mapping[typing.Any, typing.Any]] = None,
Expand All @@ -63,7 +63,7 @@ def __init__(
else:
self.log_output = log_output

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

def is_connectable(self) -> bool:
"""Establishes a socket connection to determine if the service running
Expand Down Expand Up @@ -157,7 +159,11 @@ def _terminate_process(self) -> None:
silently ignores errors here.
"""
try:
stdin, stdout, stderr = self.process.stdin, self.process.stdout, self.process.stderr
stdin, stdout, stderr = (
self.process.stdin,
self.process.stdout,
self.process.stderr,
)
for stream in stdin, stdout, stderr:
try:
stream.close() # type: ignore
Expand Down Expand Up @@ -198,7 +204,9 @@ def _start_process(self, path: str) -> None:
start_info = None
if system() == "Windows":
start_info = subprocess.STARTUPINFO()
start_info.dwFlags = subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
start_info.dwFlags = (
subprocess.CREATE_NEW_CONSOLE | subprocess.STARTF_USESHOWWINDOW
)
start_info.wShowWindow = subprocess.SW_HIDE

self.process = subprocess.Popen(
Expand Down

0 comments on commit 8ea4318

Please sign in to comment.