@@ -861,10 +861,19 @@ def _uc_gui_click_captcha(
861
861
visible_iframe = False
862
862
if (
863
863
frame != "iframe"
864
- and driver .is_element_present ('[name*="cf-turnstile-"]' )
865
- and driver .is_element_present ("%s div[style]" % frame )
864
+ and driver .is_element_present (
865
+ "%s .cf-turnstile-wrapper" % frame
866
+ )
867
+ ):
868
+ frame = "%s .cf-turnstile-wrapper" % frame
869
+ elif (
870
+ frame != "iframe"
871
+ and driver .is_element_present (
872
+ '%s [name*="cf-turnstile"]' % frame
873
+ )
874
+ and driver .is_element_present ("%s div" % frame )
866
875
):
867
- frame = "%s div[style] " % frame
876
+ frame = "%s div" % frame
868
877
elif (
869
878
driver .is_element_present ('[name*="cf-turnstile-"]' )
870
879
and driver .is_element_present ("div.spacer div" )
@@ -877,47 +886,21 @@ def _uc_gui_click_captcha(
877
886
)
878
887
):
879
888
frame = '[data-testid*="challenge-"] div'
880
- elif (
881
- (
882
- driver .is_element_present ('[name*="cf-turnstile-"]' )
883
- or driver .is_element_present ('[id*="cf-turnstile-"]' )
884
- )
885
- and driver .is_element_present (
886
- 'form div div[style*="margin"][style*="padding"]'
887
- )
888
- ):
889
- frame = 'form div div[style*="margin"][style*="padding"]'
890
- elif (
891
- frame != "iframe"
892
- and driver .is_element_present (
893
- "%s .cf-turnstile-wrapper" % frame
894
- )
889
+ elif driver .is_element_present (
890
+ 'form div:not([class]):has(input[name*="cf-turn"])'
895
891
):
896
- frame = "%s . cf-turnstile-wrapper" % frame
892
+ frame = 'form div:not([class]):has(input[name*=" cf-turn"])'
897
893
elif (
898
- frame != "iframe"
899
- and driver .is_element_present (
900
- '%s [name*="cf-turnstile"]' % frame
901
- )
902
- and driver .is_element_present ("%s div" % frame )
894
+ driver .is_element_present ('[src*="/turnstile/"]' )
895
+ and driver .is_element_present ("form div:not(:has(*))" )
903
896
):
904
- frame = "%s div" % frame
897
+ frame = "form div:not(:has(*))"
905
898
elif driver .is_element_present (".cf-turnstile-wrapper" ):
906
899
frame = ".cf-turnstile-wrapper"
907
900
elif driver .is_element_present (
908
901
'[data-callback="onCaptchaSuccess"]'
909
902
):
910
903
frame = '[data-callback="onCaptchaSuccess"]'
911
- elif (
912
- (
913
- driver .is_element_present ('[name*="cf-turnstile-"]' )
914
- or driver .is_element_present ('[id*="cf-turnstile-"]' )
915
- )
916
- and driver .is_element_present (
917
- 'div > div > [style*="margin"][style*="padding"]'
918
- )
919
- ):
920
- frame = 'div > div > [style*="margin"][style*="padding"]'
921
904
else :
922
905
return
923
906
if driver .is_element_present ('form[class*=center]' ):
@@ -1100,6 +1083,8 @@ def _uc_gui_handle_captcha(
1100
1083
driver .minimize_window ()
1101
1084
driver .set_window_rect (win_x , win_y , width , height )
1102
1085
time .sleep (0.33 )
1086
+ tab_up_first = False
1087
+ special_form = False
1103
1088
if ctype == "cf_t" :
1104
1089
if (
1105
1090
driver .is_element_present (".cf-turnstile-wrapper iframe" )
@@ -1128,26 +1113,18 @@ def _uc_gui_handle_captcha(
1128
1113
)
1129
1114
):
1130
1115
frame = '[data-testid*="challenge-"] div'
1131
- elif (
1132
- (
1133
- driver .is_element_present ('[name*="cf-turnstile-"]' )
1134
- or driver .is_element_present ('[id*="cf-turnstile-"]' )
1135
- )
1136
- and driver .is_element_present (
1137
- 'form div div[style*="margin"][style*="padding"]'
1138
- )
1116
+ elif driver .is_element_present (
1117
+ 'form div:not([class]):has(input[name*="cf-turn"])'
1139
1118
):
1140
- frame = 'form div div[style*="margin"][style*="padding"]'
1119
+ frame = 'form div:not([class]):has(input[name*="cf-turn"])'
1120
+ tab_up_first = True
1121
+ special_form = True
1141
1122
elif (
1142
- (
1143
- driver .is_element_present ('[name*="cf-turnstile-"]' )
1144
- or driver .is_element_present ('[id*="cf-turnstile-"]' )
1145
- )
1146
- and driver .is_element_present (
1147
- 'div > div > [style*="margin"][style*="padding"]'
1148
- )
1123
+ driver .is_element_present ('[src*="/turnstile/"]' )
1124
+ and driver .is_element_present ("form div:not(:has(*))" )
1149
1125
):
1150
- frame = 'div > div > [style*="margin"][style*="padding"]'
1126
+ frame = "form div:not(:has(*))"
1127
+ tab_up_first = True
1151
1128
else :
1152
1129
return
1153
1130
else :
@@ -1172,13 +1149,18 @@ def _uc_gui_handle_captcha(
1172
1149
if ctype == "g_rc" :
1173
1150
selector = "span#recaptcha-anchor"
1174
1151
found_checkbox = False
1175
- for i in range (24 ):
1152
+ if tab_up_first :
1153
+ for i in range (10 ):
1154
+ pyautogui .hotkey ("shift" , "tab" )
1155
+ time .sleep (0.027 )
1156
+ for i in range (34 ):
1176
1157
pyautogui .press ("\t " )
1177
- time .sleep (0.02 )
1158
+ time .sleep (0.027 )
1178
1159
active_element_css = js_utils .get_active_element_css (driver )
1179
1160
if (
1180
1161
active_element_css .startswith (selector )
1181
1162
or active_element_css .endswith (" > div" * 2 )
1163
+ or (special_form and active_element_css .endswith (" div" ))
1182
1164
):
1183
1165
found_checkbox = True
1184
1166
break
0 commit comments