@@ -680,6 +680,8 @@ def get_gui_element_position(driver, selector):
680
680
viewport_height = driver .execute_script ("return window.innerHeight;" )
681
681
viewport_x = window_rect ["x" ] + element_rect ["x" ]
682
682
viewport_y = window_bottom_y - viewport_height + element_rect ["y" ]
683
+ y_scroll_offset = driver .execute_script ("return window.pageYOffset;" )
684
+ viewport_y = viewport_y - y_scroll_offset
683
685
return (viewport_x , viewport_y )
684
686
685
687
@@ -688,7 +690,7 @@ def _uc_gui_click_x_y(driver, x, y, timeframe=0.25, uc_lock=False):
688
690
import pyautogui
689
691
pyautogui = get_configured_pyautogui (pyautogui )
690
692
screen_width , screen_height = pyautogui .size ()
691
- if x > screen_width or y > screen_height :
693
+ if x < 0 or y < 0 or x > screen_width or y > screen_height :
692
694
raise Exception (
693
695
"PyAutoGUI cannot click on point (%s, %s)"
694
696
" outside screen. (Width: %s, Height: %s)"
@@ -807,6 +809,16 @@ def _uc_gui_click_captcha(
807
809
frame = '[data-callback="onCaptchaSuccess"]'
808
810
else :
809
811
return
812
+ if driver .is_element_present ('form[class*=center]' ):
813
+ script = (
814
+ """var $elements = document.querySelectorAll('form');
815
+ var index = 0, length = $elements.length;
816
+ for(; index < length; index++){
817
+ the_class = $elements[index].getAttribute('class');
818
+ new_class = the_class.replaceAll('center', 'left');
819
+ $elements[index].setAttribute('class', new_class);}"""
820
+ )
821
+ driver .execute_script (script )
810
822
if not is_in_frame or needs_switch :
811
823
# Currently not in frame (or nested frame outside CF one)
812
824
try :
@@ -977,7 +989,7 @@ def uc_gui_handle_cf(driver, frame="iframe"):
977
989
return
978
990
try :
979
991
found_checkbox = False
980
- for i in range (10 ):
992
+ for i in range (24 ):
981
993
pyautogui .press ("\t " )
982
994
time .sleep (0.02 )
983
995
active_element_css = js_utils .get_active_element_css (driver )
@@ -987,7 +999,6 @@ def uc_gui_handle_cf(driver, frame="iframe"):
987
999
time .sleep (0.02 )
988
1000
if not found_checkbox :
989
1001
return
990
- driver .execute_script ('document.querySelector("input").focus()' )
991
1002
except Exception :
992
1003
try :
993
1004
driver .switch_to .default_content ()
0 commit comments