1- """Add CDP methods to extend the driver """
1+ """The CDP Mode API (sync format), which wraps the async format. """
22import asyncio
33import fasteners
44import mycdp
@@ -2035,7 +2035,7 @@ def gui_write(self, text):
20352035 self .__slow_mode_pause_if_set ()
20362036 self .loop .run_until_complete (self .page .sleep (0.025 ))
20372037
2038- def __gui_click_x_y (self , x , y , timeframe = 0.25 , uc_lock = False ):
2038+ def __gui_click_x_y (self , x , y , timeframe = 0.27 , uc_lock = False ):
20392039 self .__install_pyautogui_if_missing ()
20402040 import pyautogui
20412041 pyautogui = self .__get_configured_pyautogui (pyautogui )
@@ -2065,7 +2065,7 @@ def __gui_click_x_y(self, x, y, timeframe=0.25, uc_lock=False):
20652065 print (" <DEBUG> pyautogui.click(%s, %s)" % (x , y ))
20662066 pyautogui .click (x = x , y = y )
20672067
2068- def gui_click_x_y (self , x , y , timeframe = 0.25 ):
2068+ def gui_click_x_y (self , x , y , timeframe = 0.27 ):
20692069 gui_lock = FileLock (constants .MultiBrowser .PYAUTOGUILOCK )
20702070 with gui_lock : # Prevent issues with multiple processes
20712071 self .__make_sure_pyautogui_lock_is_writable ()
@@ -2097,7 +2097,7 @@ def gui_click_x_y(self, x, y, timeframe=0.25):
20972097 self .bring_active_window_to_front ()
20982098 self .__gui_click_x_y (x , y , timeframe = timeframe , uc_lock = False )
20992099
2100- def gui_click_element (self , selector , timeframe = 0.25 ):
2100+ def gui_click_element (self , selector , timeframe = 0.27 ):
21012101 self .__slow_mode_pause_if_set ()
21022102 x , y = self .get_gui_element_center (selector )
21032103 self .__add_light_pause ()
@@ -2106,7 +2106,7 @@ def gui_click_element(self, selector, timeframe=0.25):
21062106 self .loop .run_until_complete (self .page .wait (0.2 ))
21072107
21082108 def gui_click_with_offset (
2109- self , selector , x , y , timeframe = 0.25 , center = False
2109+ self , selector , x , y , timeframe = 0.27 , center = False
21102110 ):
21112111 """Click an element at an {X,Y}-offset location.
21122112 {0,0} is the top-left corner of the element.
@@ -2577,7 +2577,7 @@ def __click_captcha(self, use_cdp=False):
25772577 return True
25782578 return False
25792579
2580- def __gui_drag_drop (self , x1 , y1 , x2 , y2 , timeframe = 0.25 , uc_lock = False ):
2580+ def __gui_drag_drop (self , x1 , y1 , x2 , y2 , timeframe = 0.27 , uc_lock = False ):
25812581 self .__install_pyautogui_if_missing ()
25822582 import pyautogui
25832583 pyautogui = self .__get_configured_pyautogui (pyautogui )
@@ -2672,7 +2672,11 @@ def gui_click_and_hold(self, selector, timeframe=0.35):
26722672 self .__add_light_pause ()
26732673 self .gui_drag_drop_points (x , y , x , y , timeframe = timeframe )
26742674
2675- def __gui_hover_x_y (self , x , y , timeframe = 0.25 , uc_lock = False ):
2675+ def gui_move_to_element (self , selector , timeframe = 0.27 ):
2676+ """Same as gui_hover_element()"""
2677+ return self .gui_hover_element (selector , timeframe = timeframe )
2678+
2679+ def __gui_hover_x_y (self , x , y , timeframe = 0.27 , uc_lock = False ):
26762680 self .__install_pyautogui_if_missing ()
26772681 import pyautogui
26782682 pyautogui = self .__get_configured_pyautogui (pyautogui )
@@ -2697,7 +2701,7 @@ def __gui_hover_x_y(self, x, y, timeframe=0.25, uc_lock=False):
26972701 pyautogui .moveTo (x , y , timeframe , pyautogui .easeOutQuad )
26982702 time .sleep (0.056 )
26992703
2700- def gui_hover_x_y (self , x , y , timeframe = 0.25 ):
2704+ def gui_hover_x_y (self , x , y , timeframe = 0.27 ):
27012705 gui_lock = FileLock (constants .MultiBrowser .PYAUTOGUILOCK )
27022706 with gui_lock : # Prevent issues with multiple processes
27032707 self .__install_pyautogui_if_missing ()
@@ -2748,7 +2752,12 @@ def gui_hover_x_y(self, x, y, timeframe=0.25):
27482752 self .bring_active_window_to_front ()
27492753 self .__gui_hover_x_y (x , y , timeframe = timeframe , uc_lock = False )
27502754
2751- def gui_hover_element (self , selector , timeframe = 0.25 ):
2755+ def gui_hover_element (self , selector , timeframe = 0.27 ):
2756+ try :
2757+ self .__verify_pyautogui_has_a_headed_browser ()
2758+ except Exception :
2759+ self .hover_element (selector , timeframe = timeframe )
2760+ return
27522761 self .__slow_mode_pause_if_set ()
27532762 element_rect = self .get_gui_element_rect (selector )
27542763 width = element_rect ["width" ]
@@ -2760,7 +2769,7 @@ def gui_hover_element(self, selector, timeframe=0.25):
27602769 self .__slow_mode_pause_if_set ()
27612770 self .loop .run_until_complete (self .page .wait (0.1 ))
27622771
2763- def hover_element (self , selector , timeframe = 0.25 ):
2772+ def hover_element (self , selector , timeframe = 0.27 ):
27642773 element = self .select (selector )
27652774 gui_lock = FileLock (constants .MultiBrowser .PYAUTOGUILOCK )
27662775 with gui_lock :
0 commit comments