@@ -728,8 +728,23 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
728
728
install_pyautogui_if_missing (driver )
729
729
import pyautogui
730
730
pyautogui = get_configured_pyautogui (pyautogui )
731
+ connected = True
732
+ width_ratio = 1.0
731
733
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 :
733
748
window_rect = driver .get_window_rect ()
734
749
width = window_rect ["width" ]
735
750
height = window_rect ["height" ]
@@ -751,13 +766,24 @@ def uc_gui_click_x_y(driver, x, y, timeframe=0.25):
751
766
sb_config ._saved_width_ratio = width_ratio
752
767
driver .minimize_window ()
753
768
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 :
754
777
x = x * width_ratio
755
778
y = y * width_ratio
756
779
_uc_gui_click_x_y (driver , x , y , timeframe = timeframe , uc_lock = False )
757
780
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
761
787
_uc_gui_click_x_y (driver , x , y , timeframe = timeframe , uc_lock = False )
762
788
763
789
@@ -958,21 +984,20 @@ def _uc_gui_click_captcha(
958
984
pass
959
985
reconnect_time = (float (constants .UC .RECONNECT_TIME ) / 2.0 ) + 0.5
960
986
if IS_LINUX :
961
- reconnect_time = constants .UC .RECONNECT_TIME + 0.15
987
+ reconnect_time = constants .UC .RECONNECT_TIME + 0.2
962
988
if not x or not y :
963
989
reconnect_time = 1 # Make it quick (it already failed)
964
990
driver .reconnect (reconnect_time )
965
- if blind :
991
+ if blind or ( IS_LINUX and "Just a moment" in driver . title ) :
966
992
retry = True
993
+ blind = True
967
994
if retry and x and y and _on_a_captcha_page (driver ):
968
995
with gui_lock : # Prevent issues with multiple processes
969
996
# Make sure the window is on top
970
997
page_actions .switch_to_window (
971
998
driver , driver .current_window_handle , 2 , uc_lock = False
972
999
)
973
- if not driver .is_element_present ("iframe" ):
974
- return
975
- else :
1000
+ if driver .is_element_present ("iframe" ):
976
1001
try :
977
1002
driver .switch_to_frame (frame )
978
1003
except Exception :
@@ -1179,7 +1204,7 @@ def _uc_gui_handle_captcha(
1179
1204
pass
1180
1205
reconnect_time = (float (constants .UC .RECONNECT_TIME ) / 2.0 ) + 0.5
1181
1206
if IS_LINUX :
1182
- reconnect_time = constants .UC .RECONNECT_TIME + 0.15
1207
+ reconnect_time = constants .UC .RECONNECT_TIME + 0.2
1183
1208
driver .reconnect (reconnect_time )
1184
1209
1185
1210
0 commit comments