Skip to content

Commit 59fa77c

Browse files
authored
[py] update logging to match other bindings (#11990)
* [py] update logging to match other bindings * [py] Deleting a test we do not need anymore * [py] Deleting a test we do not need anymore --------- Co-authored-by: Diego Molina <[email protected]> Co-authored-by: Diego Molina <[email protected]> Fixes #11928
1 parent 66e51be commit 59fa77c

2 files changed

Lines changed: 8 additions & 24 deletions

File tree

py/selenium/webdriver/common/selenium_manager.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,9 @@ def driver_location(self, options: BaseOptions) -> str:
7070
:Returns: The driver path to use
7171
"""
7272

73-
browser = options.capabilities["browserName"]
74-
75-
allowed_browsers = {
76-
"chrome": "chrome",
77-
"firefox": "firefox",
78-
"edge": "edge",
79-
"MicrosoftEdge": "edge",
80-
"ie": "iexplorer",
81-
}
73+
logger.info("Applicable driver not found; attempting to install with Selenium Manager (Beta)")
8274

83-
if browser not in allowed_browsers.keys():
84-
raise SeleniumManagerException(
85-
f"{browser} is not a valid browser. Choose one of: {list(allowed_browsers.keys())}"
86-
)
87-
88-
browser = allowed_browsers[browser]
75+
browser = options.capabilities["browserName"]
8976

9077
args = [str(self.get_binary()), "--browser", browser, "--output", "json"]
9178

@@ -98,6 +85,9 @@ def driver_location(self, options: BaseOptions) -> str:
9885
args.append("--browser-path")
9986
args.append(str(binary_location))
10087

88+
if logger.getEffectiveLevel() == logging.DEBUG:
89+
args.append("--debug")
90+
10191
result = self.run(args)
10292
executable = result.split("\t")[-1].strip()
10393
logger.debug(f"Using driver at: {executable}")
@@ -112,7 +102,7 @@ def run(args: List[str]) -> str:
112102
:Returns: The log string containing the driver location.
113103
"""
114104
command = " ".join(args)
115-
logger.info(f"Executing: {command}")
105+
logger.debug(f"Executing process: {command}")
116106
completed_proc = subprocess.run(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
117107
stdout = completed_proc.stdout.decode("utf-8").rstrip("\n")
118108
stderr = completed_proc.stderr.decode("utf-8").rstrip("\n")
@@ -125,4 +115,6 @@ def run(args: List[str]) -> str:
125115
for item in output["logs"]:
126116
if item["level"] == "WARN":
127117
logger.warning(item["message"])
118+
if item["level"] == "DEBUG":
119+
logger.debug(item["message"])
128120
return result

py/test/selenium/webdriver/common/selenium_manager_tests.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,6 @@
2424
from selenium.webdriver.common.selenium_manager import SeleniumManager
2525

2626

27-
def test_non_supported_browser_raises_sme():
28-
msg = r"foo is not a valid browser. Choose one of: \['chrome', 'firefox', 'edge', 'MicrosoftEdge', 'ie'\]"
29-
with pytest.raises(SeleniumManagerException, match=msg):
30-
options = Options()
31-
options.capabilities["browserName"] = "foo"
32-
_ = SeleniumManager().driver_location(options)
33-
34-
3527
def test_browser_version_is_used_for_sm(mocker):
3628
import subprocess
3729

0 commit comments

Comments
 (0)