Skip to content

Commit 33c6706

Browse files
lauromouradiemol
andauthored
py: Ensure DRIVER_PATH_ENV_KEY defaults to string (#14862)
[py] Avoid os.getenv error if driver_path_env_key is not set Follow up to PR #14528, to avoid `os.getenv` raising `TypeError` in `env_path` when `driver_path_env_key` is not passed to `Service` constructor. Co-authored-by: Diego Molina <[email protected]>
1 parent 50cbca9 commit 33c6706

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

py/selenium/webdriver/common/service.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class Service(ABC):
5050
:param port: Port for the service to run on, defaults to 0 where the operating system will decide.
5151
:param log_output: (Optional) int representation of STDOUT/DEVNULL, any IO instance or String path to file.
5252
:param env: (Optional) Mapping of environment variables for the new process, defaults to `os.environ`.
53+
:param driver_path_env_key: (Optional) Environment variable to use to get the path to the driver executable.
5354
"""
5455

5556
def __init__(
@@ -245,4 +246,6 @@ def _start_process(self, path: str) -> None:
245246
raise
246247

247248
def env_path(self) -> Optional[str]:
248-
return os.getenv(self.DRIVER_PATH_ENV_KEY, None)
249+
if self.DRIVER_PATH_ENV_KEY:
250+
return os.getenv(self.DRIVER_PATH_ENV_KEY, None)
251+
return None

0 commit comments

Comments
 (0)