Skip to content

Commit

Permalink
Modified method for getting driver path within atests
Browse files Browse the repository at this point in the history
  • Loading branch information
emanlove committed May 18, 2024
1 parent e6d7b6c commit f4264bd
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions atest/resources/testlibs/get_driver_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

0 comments on commit f4264bd

Please sign in to comment.