@@ -1227,15 +1227,23 @@ def get_element_rect(self, selector, timeout=None):
12271227        if  not  timeout :
12281228            timeout  =  settings .SMALL_TIMEOUT 
12291229        selector  =  self .__convert_to_css_if_xpath (selector )
1230-         self .select (selector , timeout = timeout )
1230+         element   =   self .select (selector , timeout = timeout )
12311231        self .__add_light_pause ()
1232-         coordinates  =  self .loop .run_until_complete (
1233-             self .page .js_dumps (
1234-                 """document.querySelector""" 
1235-                 """('%s').getBoundingClientRect()""" 
1236-                 %  js_utils .escape_quotes_if_needed (re .escape (selector ))
1232+         coordinates  =  None 
1233+         if  ":contains("  in  selector :
1234+             position  =  element .get_position ()
1235+             x  =  position .x 
1236+             y  =  position .y 
1237+             width  =  position .width 
1238+             height  =  position .height 
1239+             coordinates  =  {"x" : x , "y" : y , "width" : width , "height" : height }
1240+         else :
1241+             coordinates  =  self .loop .run_until_complete (
1242+                 self .page .js_dumps (
1243+                     """document.querySelector('%s').getBoundingClientRect()""" 
1244+                     %  js_utils .escape_quotes_if_needed (re .escape (selector ))
1245+                 )
12371246            )
1238-         )
12391247        return  coordinates 
12401248
12411249    def  get_element_size (self , selector , timeout = None ):
@@ -1665,6 +1673,14 @@ def gui_drag_and_drop(self, drag_selector, drop_selector, timeframe=0.35):
16651673        self .__add_light_pause ()
16661674        self .gui_drag_drop_points (x1 , y1 , x2 , y2 , timeframe = timeframe )
16671675
1676+     def  gui_click_and_hold (self , selector , timeframe = 0.35 ):
1677+         """Use PyAutoGUI to click-and-hold a selector.""" 
1678+         self .__slow_mode_pause_if_set ()
1679+         self .bring_active_window_to_front ()
1680+         x , y  =  self .get_gui_element_center (selector )
1681+         self .__add_light_pause ()
1682+         self .gui_drag_drop_points (x , y , x , y , timeframe = timeframe )
1683+ 
16681684    def  __gui_hover_x_y (self , x , y , timeframe = 0.25 , uc_lock = False ):
16691685        self .__install_pyautogui_if_missing ()
16701686        import  pyautogui 
0 commit comments