diff --git a/atest/resources/testlibs/get_driver_path.py b/atest/resources/testlibs/get_driver_path.py index 68042963f..95c11e924 100644 --- a/atest/resources/testlibs/get_driver_path.py +++ b/atest/resources/testlibs/get_driver_path.py @@ -21,27 +21,21 @@ def _import_options(self, browser): from selenium import webdriver from selenium.webdriver.common import driver_finder import importlib +import inspect def get_driver_path(browser): browser = browser.lower().replace("headless_", "", 1) service = importlib.import_module(f"selenium.webdriver.{browser}.service") options = importlib.import_module(f"selenium.webdriver.{browser}.options") - # finder = driver_finder.DriverFinder() - # Selenium v4.19.0 and prior - try: + args = inspect.signature(driver_finder.DriverFinder.__init__).parameters.keys() + if ('service' in args) and ('options' in args): + # Selenium V4.20.0 or greater + finder = driver_finder.DriverFinder(service.Service(), options.Options()) + return finder.get_driver_path() + else: + # Selenium v4.19.0 and prior finder = driver_finder.DriverFinder() func = getattr(finder, 'get_path') return finder.get_path(service.Service(), options.Options()) - except (AttributeError, TypeError): - pass - - # Selenium V4.20.0 - try: - finder = driver_finder.DriverFinder(service.Service(), options.Options()) - return finder.get_driver_drivepath() - except: - pass - - raise Exception('Unable to determine driver path') \ No newline at end of file