Skip to content

Commit 0d6c255

Browse files
committedDec 15, 2024
Add method to get element at coordinates
1 parent 57e7b2b commit 0d6c255

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎help_docs/method_summary.md

+2
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ self.execute_async_script(script, timeout=None)
227227

228228
self.safe_execute_script(script, *args, **kwargs)
229229

230+
self.get_element_at_x_y(x, y)
231+
230232
self.get_gui_element_rect(selector, by="css selector")
231233

232234
self.get_gui_element_center(selector, by="css selector")

‎seleniumbase/fixtures/base_case.py

+8
Original file line numberDiff line numberDiff line change
@@ -3416,6 +3416,14 @@ def safe_execute_script(self, script, *args, **kwargs):
34163416
self.activate_jquery()
34173417
return self.driver.execute_script(script, *args, **kwargs)
34183418

3419+
def get_element_at_x_y(self, x, y):
3420+
"""Return element at current window's x,y coordinates."""
3421+
self.__check_scope()
3422+
self._check_browser()
3423+
return self.execute_script(
3424+
"return document.elementFromPoint(%s, %s);" % (x, y)
3425+
)
3426+
34193427
def get_gui_element_rect(self, selector, by="css selector"):
34203428
"""Very similar to element.rect, but the x, y coordinates are
34213429
relative to the entire screen, rather than the browser window.

0 commit comments

Comments
 (0)
Please sign in to comment.