From 0755e6859832f3bc78bfc07b888c2cacce9879a4 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Mon, 18 Sep 2023 16:07:29 -0700 Subject: [PATCH] [py] do not check sys.platform if setting environment variable --- .../webdriver/common/selenium_manager.py | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/py/selenium/webdriver/common/selenium_manager.py b/py/selenium/webdriver/common/selenium_manager.py index 4698d98e30354..2fd24aa7f6763 100644 --- a/py/selenium/webdriver/common/selenium_manager.py +++ b/py/selenium/webdriver/common/selenium_manager.py @@ -40,18 +40,23 @@ def get_binary() -> Path: :Returns: The Selenium Manager executable location """ - directory = "linux" + file = "selenium-manager" if os.getenv("SE_MANAGER_PATH"): - directory = os.getenv("SE_MANAGER_PATH") - file = "" - if sys.platform == "darwin": - directory = "macos" - elif sys.platform in ("win32", "cygwin"): - directory = "windows" - file = "selenium-manager.exe" - - path = Path(__file__).parent.joinpath(directory, file) + path = os.getenv("SE_MANAGER_PATH") + else: + platform = sys.platform + + dirs = { + "darwin": "macos", + "win32": "windows", + "cygwin": "windows", + } + + directory = dirs.get(platform) if dirs.get(platform) else platform + file = "selenium-manager.exe" if directory == "windows" else "selenium-manager" + + path = Path(__file__).parent.joinpath(directory, file) if not path.is_file() and os.environ["CONDA_PREFIX"]: # conda has a separate package selenium-manager, installs in bin