1818from seleniumbase import drivers # webdriver storage folder for SeleniumBase
1919from seleniumbase import extensions # browser extensions storage folder
2020from seleniumbase .config import settings
21+ from seleniumbase .core import detect_b_ver
2122from seleniumbase .core import download_helper
2223from seleniumbase .core import proxy_helper
2324from seleniumbase .fixtures import constants
@@ -190,8 +191,10 @@ def has_cf(text):
190191 if (
191192 "<title>Just a moment...</title>" in text
192193 or "<title>403 Forbidden</title>" in text
194+ or "Permission Denied</title>" in text
193195 or 'id="challenge-error-text"' in text
194196 or 'action="/?__cf_chl_f_tk' in text
197+ or 'src="chromedriver.js"' in text
195198 or 'id="challenge-form"' in text
196199 or "window._cf_chl_opt" in text
197200 ):
@@ -218,11 +221,11 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
218221 pass
219222 if special :
220223 with driver :
221- time .sleep (0.2 )
224+ time .sleep (0.18 )
222225 driver .execute_script ('window.open("%s","_blank");' % url )
223226 driver .close ()
224227 driver .switch_to .window (driver .window_handles [- 1 ])
225- time .sleep (0.2 )
228+ time .sleep (0.02 )
226229 else :
227230 driver .open (url ) # The original one
228231 else :
@@ -233,9 +236,9 @@ def uc_special_open_if_cf(driver, url, proxy_string=None):
233236def uc_open (driver , url ):
234237 if (url .startswith ("http:" ) or url .startswith ("https:" )):
235238 with driver :
236- time .sleep (0.2 )
239+ time .sleep (0.18 )
237240 driver .open (url )
238- time .sleep (0.2 )
241+ time .sleep (0.02 )
239242 else :
240243 driver .open (url ) # The original one
241244 return None
@@ -244,11 +247,11 @@ def uc_open(driver, url):
244247def uc_open_with_tab (driver , url ):
245248 if (url .startswith ("http:" ) or url .startswith ("https:" )):
246249 with driver :
247- time .sleep (0.2 )
250+ time .sleep (0.18 )
248251 driver .execute_script ('window.open("%s","_blank");' % url )
249252 driver .close ()
250253 driver .switch_to .window (driver .window_handles [- 1 ])
251- time .sleep (0.2 )
254+ time .sleep (0.02 )
252255 else :
253256 driver .open (url ) # The original one
254257 return None
@@ -312,7 +315,7 @@ def get_valid_binary_names_for_browser(browser):
312315 else :
313316 raise Exception ("Could not determine OS, or unsupported!" )
314317 else :
315- raise Exception ("Invalid combination for os browser binaries!" )
318+ raise Exception ("Invalid combination for OS browser binaries!" )
316319
317320
318321def _repair_chromedriver (chrome_options , headless_options , mcv = None ):
@@ -870,7 +873,12 @@ def _set_chrome_options(
870873 )
871874 except Exception :
872875 pass
873- if len (chromium_arg_item ) >= 3 :
876+ if "set-binary" in chromium_arg_item and not binary_location :
877+ br_app = "google-chrome"
878+ binary_loc = detect_b_ver .get_binary_location (br_app )
879+ if os .path .exists (binary_loc ):
880+ binary_location = binary_loc
881+ elif len (chromium_arg_item ) >= 3 :
874882 chrome_options .add_argument (chromium_arg_item )
875883 if devtools and not headless :
876884 chrome_options .add_argument ("--auto-open-devtools-for-tabs" )
@@ -1166,6 +1174,8 @@ def get_driver(
11661174 "that includes the driver filename at the end of it!"
11671175 "\n (Will use default settings...)\n " % binary_location
11681176 )
1177+ # Example of a valid binary location path - MacOS:
1178+ # "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
11691179 binary_location = None
11701180 else :
11711181 binary_name = binary_location .split ("/" )[- 1 ].split ("\\ " )[- 1 ]
@@ -2251,8 +2261,6 @@ def get_local_driver(
22512261 use_version = "latest"
22522262 major_edge_version = None
22532263 try :
2254- from seleniumbase .core import detect_b_ver
2255-
22562264 if binary_location :
22572265 try :
22582266 major_edge_version = (
@@ -2480,8 +2488,6 @@ def get_local_driver(
24802488 )
24812489 edge_options .add_argument ("--disable-browser-side-navigation" )
24822490 edge_options .add_argument ("--disable-translate" )
2483- if binary_location :
2484- edge_options .binary_location = binary_location
24852491 if not enable_ws :
24862492 edge_options .add_argument ("--disable-web-security" )
24872493 edge_options .add_argument ("--homepage=about:blank" )
@@ -2585,8 +2591,15 @@ def get_local_driver(
25852591 chromium_arg_item = "-" + chromium_arg_item
25862592 else :
25872593 chromium_arg_item = "--" + chromium_arg_item
2588- if len (chromium_arg_item ) >= 3 :
2594+ if "set-binary" in chromium_arg_item and not binary_location :
2595+ br_app = "edge"
2596+ binary_loc = detect_b_ver .get_binary_location (br_app )
2597+ if os .path .exists (binary_loc ):
2598+ binary_location = binary_loc
2599+ elif len (chromium_arg_item ) >= 3 :
25892600 edge_options .add_argument (chromium_arg_item )
2601+ if binary_location :
2602+ edge_options .binary_location = binary_location
25902603 if selenium4_or_newer :
25912604 try :
25922605 service = EdgeService (
@@ -2884,8 +2897,6 @@ def get_local_driver(
28842897 major_chrome_version = None
28852898 if selenium4_or_newer :
28862899 try :
2887- from seleniumbase .core import detect_b_ver
2888-
28892900 if binary_location :
28902901 try :
28912902 major_chrome_version = (
0 commit comments