@@ -239,6 +239,7 @@ def Driver(
239239 from seleniumbase import config as sb_config
240240 from seleniumbase .config import settings
241241 from seleniumbase .core import browser_launcher
242+ from seleniumbase .core import detect_b_ver
242243 from seleniumbase .fixtures import constants
243244 from seleniumbase .fixtures import shared_utils
244245
@@ -271,10 +272,37 @@ def Driver(
271272 )
272273 elif existing_runner :
273274 sb_config ._context_of_runner = True
275+ sb_config ._browser_shortcut = None
276+ sb_config ._cdp_browser = None
277+ sb_config ._cdp_bin_loc = None
274278 browser_changes = 0
275279 browser_set = None
276280 browser_text = None
277281 browser_list = []
282+ # Check if binary-location in options
283+ bin_loc_in_options = False
284+ if (
285+ binary_location
286+ and len (str (binary_location )) > 5
287+ and os .path .exists (str (binary_location ))
288+ ):
289+ bin_loc_in_options = True
290+ else :
291+ for arg in sys_argv :
292+ if arg in ["--binary-location" , "--binary_location" , "--bl" ]:
293+ bin_loc_in_options = True
294+ if (
295+ browser
296+ and browser in constants .ChromiumSubs .chromium_subs
297+ and not bin_loc_in_options
298+ ):
299+ bin_loc = detect_b_ver .get_binary_location (browser )
300+ if bin_loc and os .path .exists (bin_loc ):
301+ if browser in bin_loc .lower ().split ("/" )[- 1 ].split ("\\ " )[- 1 ]:
302+ sb_config ._cdp_browser = browser
303+ sb_config ._cdp_bin_loc = bin_loc
304+ binary_location = bin_loc
305+ bin_loc_in_options = True
278306 # As a shortcut, you can use "--edge" instead of "--browser=edge", etc,
279307 # but you can only specify one default browser for tests. (Default: chrome)
280308 if "--browser=chrome" in sys_argv or "--browser chrome" in sys_argv :
@@ -301,6 +329,46 @@ def Driver(
301329 browser_changes += 1
302330 browser_set = "remote"
303331 browser_list .append ("--browser=remote" )
332+ if "--browser=opera" in sys_argv or "--browser opera" in sys_argv :
333+ if not bin_loc_in_options :
334+ bin_loc = detect_b_ver .get_binary_location ("opera" )
335+ if os .path .exists (bin_loc ):
336+ browser_changes += 1
337+ browser_set = "opera"
338+ sb_config ._browser_shortcut = "opera"
339+ sb_config ._cdp_browser = "opera"
340+ sb_config ._cdp_bin_loc = bin_loc
341+ browser_list .append ("--browser=opera" )
342+ if "--browser=brave" in sys_argv or "--browser brave" in sys_argv :
343+ if not bin_loc_in_options :
344+ bin_loc = detect_b_ver .get_binary_location ("brave" )
345+ if os .path .exists (bin_loc ):
346+ browser_changes += 1
347+ browser_set = "brave"
348+ sb_config ._browser_shortcut = "brave"
349+ sb_config ._cdp_browser = "brave"
350+ sb_config ._cdp_bin_loc = bin_loc
351+ browser_list .append ("--browser=brave" )
352+ if "--browser=comet" in sys_argv or "--browser comet" in sys_argv :
353+ if not bin_loc_in_options :
354+ bin_loc = detect_b_ver .get_binary_location ("comet" )
355+ if os .path .exists (bin_loc ):
356+ browser_changes += 1
357+ browser_set = "comet"
358+ sb_config ._browser_shortcut = "comet"
359+ sb_config ._cdp_browser = "comet"
360+ sb_config ._cdp_bin_loc = bin_loc
361+ browser_list .append ("--browser=comet" )
362+ if "--browser=atlas" in sys_argv or "--browser atlas" in sys_argv :
363+ if not bin_loc_in_options :
364+ bin_loc = detect_b_ver .get_binary_location ("atlas" )
365+ if os .path .exists (bin_loc ):
366+ browser_changes += 1
367+ browser_set = "atlas"
368+ sb_config ._browser_shortcut = "atlas"
369+ sb_config ._cdp_browser = "atlas"
370+ sb_config ._cdp_bin_loc = bin_loc
371+ browser_list .append ("--browser=atlas" )
304372 browser_text = browser_set
305373 if "--chrome" in sys_argv and not browser_set == "chrome" :
306374 browser_changes += 1
@@ -322,6 +390,46 @@ def Driver(
322390 browser_changes += 1
323391 browser_text = "safari"
324392 browser_list .append ("--safari" )
393+ if "--opera" in sys_argv and not browser_set == "opera" :
394+ if not bin_loc_in_options :
395+ bin_loc = detect_b_ver .get_binary_location ("opera" )
396+ if os .path .exists (bin_loc ):
397+ browser_changes += 1
398+ browser_text = "opera"
399+ sb_config ._browser_shortcut = "opera"
400+ sb_config ._cdp_browser = "opera"
401+ sb_config ._cdp_bin_loc = bin_loc
402+ browser_list .append ("--opera" )
403+ if "--brave" in sys_argv and not browser_set == "brave" :
404+ if not bin_loc_in_options :
405+ bin_loc = detect_b_ver .get_binary_location ("brave" )
406+ if os .path .exists (bin_loc ):
407+ browser_changes += 1
408+ browser_text = "brave"
409+ sb_config ._browser_shortcut = "brave"
410+ sb_config ._cdp_browser = "brave"
411+ sb_config ._cdp_bin_loc = bin_loc
412+ browser_list .append ("--brave" )
413+ if "--comet" in sys_argv and not browser_set == "comet" :
414+ if not bin_loc_in_options :
415+ bin_loc = detect_b_ver .get_binary_location ("comet" )
416+ if os .path .exists (bin_loc ):
417+ browser_changes += 1
418+ browser_text = "comet"
419+ sb_config ._browser_shortcut = "comet"
420+ sb_config ._cdp_browser = "comet"
421+ sb_config ._cdp_bin_loc = bin_loc
422+ browser_list .append ("--comet" )
423+ if "--atlas" in sys_argv and not browser_set == "atlas" :
424+ if not bin_loc_in_options :
425+ bin_loc = detect_b_ver .get_binary_location ("atlas" )
426+ if os .path .exists (bin_loc ):
427+ browser_changes += 1
428+ browser_text = "atlas"
429+ sb_config ._browser_shortcut = "atlas"
430+ sb_config ._cdp_browser = "atlas"
431+ sb_config ._cdp_bin_loc = bin_loc
432+ browser_list .append ("--atlas" )
325433 if browser_changes > 1 :
326434 message = "\n \n TOO MANY browser types were entered!"
327435 message += "\n There were %s found:\n > %s" % (
@@ -345,6 +453,10 @@ def Driver(
345453 "Browser: {%s} is not a valid browser option. "
346454 "Valid options = {%s}" % (browser , valid_browsers )
347455 )
456+ if sb_config ._browser_shortcut :
457+ browser = sb_config ._browser_shortcut
458+ if browser in constants .ChromiumSubs .chromium_subs :
459+ browser = "chrome" # Still uses chromedriver
348460 if headless is None :
349461 if "--headless" in sys_argv :
350462 headless = True
@@ -534,6 +646,8 @@ def Driver(
534646 count += 1
535647 user_agent = agent
536648 found_bl = None
649+ if hasattr (sb_config , "_cdp_bin_loc" ) and sb_config ._cdp_bin_loc :
650+ binary_location = sb_config ._cdp_bin_loc
537651 if binary_location is None and "--binary-location" in arg_join :
538652 count = 0
539653 for arg in sys_argv :
0 commit comments