2828from seleniumbase import drivers # webdriver storage folder for SeleniumBase
2929from seleniumbase .drivers import cft_drivers # chrome-for-testing
3030from seleniumbase .drivers import chs_drivers # chrome-headless-shell
31+ from seleniumbase .drivers import opera_drivers # still uses chromedriver
32+ from seleniumbase .drivers import brave_drivers # still uses chromedriver
33+ from seleniumbase .drivers import comet_drivers # still uses chromedriver
34+ from seleniumbase .drivers import atlas_drivers # still uses chromedriver
3135from seleniumbase import extensions # browser extensions storage folder
3236from seleniumbase .config import settings
3337from seleniumbase .core import detect_b_ver
4448DRIVER_DIR = os .path .dirname (os .path .realpath (drivers .__file__ ))
4549DRIVER_DIR_CFT = os .path .dirname (os .path .realpath (cft_drivers .__file__ ))
4650DRIVER_DIR_CHS = os .path .dirname (os .path .realpath (chs_drivers .__file__ ))
51+ DRIVER_DIR_OPERA = os .path .dirname (os .path .realpath (opera_drivers .__file__ ))
52+ DRIVER_DIR_BRAVE = os .path .dirname (os .path .realpath (brave_drivers .__file__ ))
53+ DRIVER_DIR_COMET = os .path .dirname (os .path .realpath (comet_drivers .__file__ ))
54+ DRIVER_DIR_ATLAS = os .path .dirname (os .path .realpath (atlas_drivers .__file__ ))
4755# Make sure that the SeleniumBase DRIVER_DIR is at the top of the System PATH
4856# (Changes to the System PATH with os.environ only last during the test run)
4957if not os .environ ["PATH" ].startswith (DRIVER_DIR ):
@@ -1218,8 +1226,8 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
12181226 driver .cdp .minimize ()
12191227 driver .cdp .set_window_rect (win_x , win_y , width , height )
12201228 if IS_WINDOWS :
1221- x = x * width_ratio
1222- y = y * width_ratio
1229+ x = x * ( width_ratio + 0.03 )
1230+ y = y * ( width_ratio - 0.03 )
12231231 _uc_gui_click_x_y (driver , x , y , timeframe = timeframe , uc_lock = False )
12241232 return
12251233 with suppress (Exception ):
@@ -1260,7 +1268,7 @@ def _uc_gui_click_captcha(
12601268 ctype = None ,
12611269):
12621270 cdp_mode_on_at_start = __is_cdp_swap_needed (driver )
1263- if cdp_mode_on_at_start and ( not ctype or ctype == "cf_t" ) :
1271+ if cdp_mode_on_at_start :
12641272 return driver .cdp .gui_click_captcha ()
12651273 _on_a_captcha_page = None
12661274 if ctype == "cf_t" :
@@ -1952,6 +1960,15 @@ def get_valid_binary_names_for_browser(browser):
19521960 raise Exception ("Invalid combination for OS browser binaries!" )
19531961
19541962
1963+ def _special_binary_exists (location , name ):
1964+ filename = str (location ).split ("/" )[- 1 ].split ("\\ " )[- 1 ]
1965+ return (
1966+ location
1967+ and str (name ).lower () in filename .lower ()
1968+ and os .path .exists (location )
1969+ )
1970+
1971+
19551972def _repair_chromedriver (chrome_options , headless_options , mcv = None ):
19561973 if mcv :
19571974 subprocess .check_call (
@@ -2960,6 +2977,14 @@ def get_driver(
29602977 and sb_config .binary_location == "chs"
29612978 ):
29622979 driver_dir = DRIVER_DIR_CHS
2980+ if _special_binary_exists (binary_location , "opera" ):
2981+ driver_dir = DRIVER_DIR_OPERA
2982+ if _special_binary_exists (binary_location , "brave" ):
2983+ driver_dir = DRIVER_DIR_BRAVE
2984+ if _special_binary_exists (binary_location , "comet" ):
2985+ driver_dir = DRIVER_DIR_COMET
2986+ if _special_binary_exists (binary_location , "atlas" ):
2987+ driver_dir = DRIVER_DIR_ATLAS
29632988 if (
29642989 hasattr (sb_config , "settings" )
29652990 and hasattr (sb_config .settings , "NEW_DRIVER_DIR" )
@@ -3919,6 +3944,18 @@ def get_local_driver(
39193944 ):
39203945 special_chrome = True
39213946 driver_dir = DRIVER_DIR_CHS
3947+ if _special_binary_exists (binary_location , "opera" ):
3948+ special_chrome = True
3949+ driver_dir = DRIVER_DIR_OPERA
3950+ if _special_binary_exists (binary_location , "brave" ):
3951+ special_chrome = True
3952+ driver_dir = DRIVER_DIR_BRAVE
3953+ if _special_binary_exists (binary_location , "comet" ):
3954+ special_chrome = True
3955+ driver_dir = DRIVER_DIR_COMET
3956+ if _special_binary_exists (binary_location , "atlas" ):
3957+ special_chrome = True
3958+ driver_dir = DRIVER_DIR_ATLAS
39223959 if (
39233960 hasattr (sb_config , "settings" )
39243961 and hasattr (sb_config .settings , "NEW_DRIVER_DIR" )
@@ -4756,6 +4793,27 @@ def get_local_driver(
47564793 )
47574794 return extend_driver (driver )
47584795 elif browser_name == constants .Browser .GOOGLE_CHROME :
4796+ set_chromium = None
4797+ if _special_binary_exists (binary_location , "opera" ):
4798+ set_chromium = "opera"
4799+ local_chromedriver = DRIVER_DIR_OPERA + "/chromedriver"
4800+ if IS_WINDOWS :
4801+ local_chromedriver = DRIVER_DIR_OPERA + "/chromedriver.exe"
4802+ if _special_binary_exists (binary_location , "brave" ):
4803+ set_chromium = "brave"
4804+ local_chromedriver = DRIVER_DIR_BRAVE + "/chromedriver"
4805+ if IS_WINDOWS :
4806+ local_chromedriver = DRIVER_DIR_BRAVE + "/chromedriver.exe"
4807+ if _special_binary_exists (binary_location , "comet" ):
4808+ set_chromium = "comet"
4809+ local_chromedriver = DRIVER_DIR_COMET + "/chromedriver"
4810+ if IS_WINDOWS :
4811+ local_chromedriver = DRIVER_DIR_COMET + "/chromedriver.exe"
4812+ if _special_binary_exists (binary_location , "atlas" ):
4813+ set_chromium = "atlas"
4814+ local_chromedriver = DRIVER_DIR_ATLAS + "/chromedriver"
4815+ if IS_WINDOWS :
4816+ local_chromedriver = DRIVER_DIR_ATLAS + "/chromedriver.exe"
47594817 try :
47604818 chrome_options = _set_chrome_options (
47614819 browser_name ,
@@ -4877,6 +4935,12 @@ def get_local_driver(
48774935 major_chrome_version = None
48784936 if major_chrome_version :
48794937 use_version = major_chrome_version
4938+ if (
4939+ set_chromium == "opera"
4940+ and use_version .isnumeric ()
4941+ and int (use_version ) < 130
4942+ ):
4943+ use_version = "130" # Special case
48804944 ch_driver_version = None
48814945 path_chromedriver = chromedriver_on_path ()
48824946 if os .path .exists (local_chromedriver ):
@@ -4894,7 +4958,7 @@ def get_local_driver(
48944958 ch_driver_version = output
48954959 if driver_version == "keep" :
48964960 driver_version = ch_driver_version
4897- elif path_chromedriver :
4961+ elif path_chromedriver and not set_chromium :
48984962 try :
48994963 make_driver_executable_if_not (path_chromedriver )
49004964 except Exception as e :
0 commit comments