@@ -728,8 +728,23 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
728728 install_pyautogui_if_missing (driver )
729729 import pyautogui
730730 pyautogui = get_configured_pyautogui (pyautogui )
731+ connected = True
732+ width_ratio = 1.0
731733 if IS_WINDOWS :
732- width_ratio = 1.0
734+ try :
735+ driver .window_handles
736+ except Exception :
737+ connected = False
738+ if (
739+ not connected
740+ and (
741+ not hasattr (sb_config , "_saved_width_ratio" )
742+ or not sb_config ._saved_width_ratio
743+ )
744+ ):
745+ driver .reconnect (0.1 )
746+ connected = True
747+ if IS_WINDOWS and connected :
733748 window_rect = driver .get_window_rect ()
734749 width = window_rect ["width" ]
735750 height = window_rect ["height" ]
@@ -751,13 +766,24 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
751766 sb_config ._saved_width_ratio = width_ratio
752767 driver .minimize_window ()
753768 driver .set_window_rect (win_x , win_y , width , height )
769+ elif (
770+ IS_WINDOWS
771+ and not connected
772+ and hasattr (sb_config , "_saved_width_ratio" )
773+ and sb_config ._saved_width_ratio
774+ ):
775+ width_ratio = sb_config ._saved_width_ratio
776+ if IS_WINDOWS :
754777 x = x * width_ratio
755778 y = y * width_ratio
756779 _uc_gui_click_x_y (driver , x , y , timeframe = timeframe , uc_lock = False )
757780 return
758- page_actions .switch_to_window (
759- driver , driver .current_window_handle , 2 , uc_lock = False
760- )
781+ try :
782+ page_actions .switch_to_window (
783+ driver , driver .current_window_handle , 2 , uc_lock = False
784+ )
785+ except Exception :
786+ pass
761787 _uc_gui_click_x_y (driver , x , y , timeframe = timeframe , uc_lock = False )
762788
763789
@@ -958,21 +984,20 @@ def _uc_gui_click_captcha(
958984 pass
959985 reconnect_time = (float (constants .UC .RECONNECT_TIME ) / 2.0 ) + 0.5
960986 if IS_LINUX :
961- reconnect_time = constants .UC .RECONNECT_TIME + 0.15
987+ reconnect_time = constants .UC .RECONNECT_TIME + 0.2
962988 if not x or not y :
963989 reconnect_time = 1 # Make it quick (it already failed)
964990 driver .reconnect (reconnect_time )
965- if blind :
991+ if blind or ( IS_LINUX and "Just a moment" in driver . title ) :
966992 retry = True
993+ blind = True
967994 if retry and x and y and _on_a_captcha_page (driver ):
968995 with gui_lock : # Prevent issues with multiple processes
969996 # Make sure the window is on top
970997 page_actions .switch_to_window (
971998 driver , driver .current_window_handle , 2 , uc_lock = False
972999 )
973- if not driver .is_element_present ("iframe" ):
974- return
975- else :
1000+ if driver .is_element_present ("iframe" ):
9761001 try :
9771002 driver .switch_to_frame (frame )
9781003 except Exception :
@@ -1179,7 +1204,7 @@ def _uc_gui_handle_captcha(
11791204 pass
11801205 reconnect_time = (float (constants .UC .RECONNECT_TIME ) / 2.0 ) + 0.5
11811206 if IS_LINUX :
1182- reconnect_time = constants .UC .RECONNECT_TIME + 0.15
1207+ reconnect_time = constants .UC .RECONNECT_TIME + 0.2
11831208 driver .reconnect (reconnect_time )
11841209
11851210
0 commit comments