Skip to content

Commit

Permalink
fix: retry_count, also allow Options pass through if set
Browse files Browse the repository at this point in the history
  • Loading branch information
duttonw committed Jan 3, 2025
1 parent e5437a6 commit f346609
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions src/behaving/web/steps/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,18 @@ def get_default_selenium_options(driver_name, args):

elif browser_name == "EDGE":
from selenium.webdriver.edge.options import Options
options = Options()
if "options" in args and isinstance(args["options"], Options):
options = args["options"]
else:
options = Options()

elif browser_name == "FIREFOX":
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.firefox.firefox_profile import FirefoxProfile
options = Options()
if "options" in args and isinstance(args["options"], Options):
options = args["options"]
else:
options = Options()

profile = args.pop("profile", None)
firefox_profile = FirefoxProfile(profile)
Expand All @@ -88,7 +94,23 @@ def get_default_selenium_options(driver_name, args):

elif browser_name == "SAFARI":
from selenium.webdriver.safari.options import Options
options = Options()
if "options" in args and isinstance(args["options"], Options):
options = args["options"]
else:
options = Options()

elif browser_name == "EDGE":
from selenium.webdriver.edge.options import Options
if "options" in args and isinstance(args["options"], Options):
options = args["options"]
else:
options = Options()
elif browser_name == "INTERNETEXPLORER":
from selenium.webdriver.ie.options import Options
if "options" in args and isinstance(args["options"], Options):
options = args["options"]
else:
options = Options()

else:
raise ValueError(f"Unsupported browser {browser_name}")
Expand Down Expand Up @@ -161,8 +183,9 @@ def named_browser(context, name):
options.set_capability(key, value)
args.pop("desired_capabilities", None)

retry_count = getattr(args, 'retry_count', 3)
context.browsers[name] = Browser(driver_name=driver_name,
retry_count=getattr(args, 'retry_count', 3),
retry_count=retry_count,
config=config,
**args)
break
Expand Down

0 comments on commit f346609

Please sign in to comment.