@@ -134,11 +134,16 @@ async def inner_html(self) -> str:
134
134
Returns:
135
135
str: The inner HTML of the element.
136
136
"""
137
- command = DomCommands .get_outer_html (self ._node ['nodeId' ])
137
+ if self ._search_method == By .XPATH :
138
+ command = DomCommands .get_outer_html (
139
+ object_id = self ._node ['objectId' ]
140
+ )
141
+ else :
142
+ command = DomCommands .get_outer_html (self ._node ['nodeId' ])
138
143
response = await self ._execute_command (command )
139
144
return response ['result' ]['outerHTML' ]
140
145
141
- async def get_bounds_by_js (self ) -> list :
146
+ async def get_bounds_using_js (self ) -> list :
142
147
"""
143
148
Retrieves the bounding box of the element using JavaScript.
144
149
@@ -197,9 +202,7 @@ async def get_element_text(self) -> str:
197
202
Returns:
198
203
str: The text of the element.
199
204
"""
200
- command = DomCommands .get_outer_html (self ._node ['nodeId' ])
201
- response = await self ._execute_command (command )
202
- outer_html = response ['result' ]['outerHTML' ]
205
+ outer_html = await self .inner_html
203
206
soup = BeautifulSoup (outer_html , 'html.parser' )
204
207
text_inside = soup .get_text (strip = True )
205
208
return text_inside
@@ -230,7 +233,7 @@ async def scroll_into_view(self):
230
233
)
231
234
await self ._execute_command (command )
232
235
233
- async def click (self ):
236
+ async def click_using_js (self ):
234
237
if self ._is_option_tag ():
235
238
return await self .click_option_tag ()
236
239
@@ -250,7 +253,7 @@ async def click(self):
250
253
'Element is not interactable.'
251
254
)
252
255
253
- async def realistic_click (self , x_offset : int = 0 , y_offset : int = 0 ):
256
+ async def click (self , x_offset : int = 0 , y_offset : int = 0 ):
254
257
if not await self ._is_element_visible ():
255
258
raise exceptions .ElementNotVisible (
256
259
'Element is not visible on the page.'
@@ -269,7 +272,7 @@ async def realistic_click(self, x_offset: int = 0, y_offset: int = 0):
269
272
position_to_click [1 ] + y_offset ,
270
273
)
271
274
except IndexError :
272
- element_bounds = await self .get_bounds_by_js ()
275
+ element_bounds = await self .get_bounds_using_js ()
273
276
element_bounds = json .loads (element_bounds )
274
277
position_to_click = (
275
278
element_bounds ['x' ] + element_bounds ['width' ] / 2 ,
0 commit comments