Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[py]: Propagate stderr to exceptions when selenium manager fails #11329

Merged
merged 11 commits into from
Dec 1, 2022
Prev Previous commit
Next Next commit
[py]: simplify command and logging in selenium manager .run()
  • Loading branch information
symonk committed Nov 30, 2022
commit f0819cc72766e599e1c4f8b3fc9ca29bbf263213
8 changes: 5 additions & 3 deletions py/selenium/webdriver/common/selenium_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,13 @@ def run(args: Tuple[str, str, str]) -> str:
- args: the components of the command being executed.
:Returns: The log string containing the driver location.
"""
logger.debug(f"Executing selenium manager with: {args}")
command = " ".join(args)
logger.debug(f"Executing: {command}")
completed_proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
symonk marked this conversation as resolved.
Show resolved Hide resolved
stdout, stderr = completed_proc.stdout.decode("utf-8"), completed_proc.stderr.decode("utf-8")
stdout = completed_proc.stdout.decode("utf-8").rstrip("\n")
stderr = completed_proc.stderr.decode("utf-8").rstrip("\n")
if completed_proc.returncode:
raise SeleniumManagerException(f"Selenium Manager exited non zero. {stdout}{stderr}")
raise SeleniumManagerException(f"Selenium manager failed for: {command}. {stderr}")
else:
# selenium manager exited 0 successfully, parse the executable path from stdout.
return stdout.split("\t")[-1].strip()