@@ -47,10 +47,18 @@ def __delete(url):
4747 raise WebDriverError ("'DELETE' request failed." ) from error
4848
4949
50+ def get_rect (driver_url , session , element ):
51+ """Get the element rectangle"""
52+ try :
53+ url = f"{ driver_url } /session/{ session } /element/{ element } /rect"
54+ return __get (url ).get ("value" )
55+ except Exception as error :
56+ raise WebDriverError (f"Failed to get the element rect." ) from error
57+
58+
5059def actions_scroll_to_element (driver_url , session , element ):
5160 """Scroll to an element simulating a mouse movement"""
5261 try :
53- url = f"{ driver_url } /session/{ session } /actions"
5462 payload = {
5563 "actions" : [
5664 {
@@ -70,12 +78,17 @@ def actions_scroll_to_element(driver_url, session, element):
7078 }
7179 ]
7280 }
73- __post (url , payload )
74- return True
81+ return actions (driver_url , session , payload )
7582 except Exception as error :
7683 raise WebDriverError (f"Failed to scroll to element." ) from error
7784
7885
86+ def actions (driver_url , session , payload ):
87+ url = f"{ driver_url } /session/{ session } /actions"
88+ __post (url , payload )
89+ return True
90+
91+
7992def submit (driver_url , session , element ):
8093 """Submit a form. It is similar to 'submit' funtion in Seleniu
8194 It is not part of W3C WebDriver. Just added for convenience
@@ -96,7 +109,6 @@ def submit(driver_url, session, element):
96109def actions_click (driver_url , session , element ):
97110 """Click an element simulating a mouse movement"""
98111 try :
99- url = f"{ driver_url } /session/{ session } /actions"
100112 payload = {
101113 "actions" : [
102114 {
@@ -126,8 +138,7 @@ def actions_click(driver_url, session, element):
126138 },
127139 ]
128140 }
129- __post (url , payload )
130- return True
141+ return actions (driver_url , session , payload )
131142 except Exception as error :
132143 raise WebDriverError (f"Failed to click the element." ) from error
133144
0 commit comments