MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / get_element_rect

Method get_element_rect

seleniumbase/core/sb_cdp.py:1585–1606  ·  view source on GitHub ↗
(self, selector, timeout=None)

Source from the content-addressed store, hash-verified

1583 return coordinates
1584
1585 def get_element_rect(self, selector, timeout=None):
1586 if not timeout:
1587 timeout = settings.SMALL_TIMEOUT
1588 selector = self.__convert_to_css_if_xpath(selector)
1589 element = self.select(selector, timeout=timeout)
1590 self.__add_light_pause()
1591 coordinates = None
1592 if ":contains(" in selector:
1593 position = element.get_position()
1594 x = position.x
1595 y = position.y
1596 width = position.width
1597 height = position.height
1598 coordinates = {"x": x, "y": y, "width": width, "height": height}
1599 else:
1600 coordinates = self.loop.run_until_complete(
1601 self.page.js_dumps(
1602 """document.querySelector('%s').getBoundingClientRect()"""
1603 % js_utils.escape_quotes_if_needed(re.escape(selector))
1604 )
1605 )
1606 return coordinates
1607
1608 def get_element_size(self, selector, timeout=None):
1609 if not timeout:

Callers 5

get_element_sizeMethod · 0.95
get_element_positionMethod · 0.95
get_gui_element_rectMethod · 0.95
__gui_click_recaptchaMethod · 0.95

Calls 4

selectMethod · 0.95
__add_light_pauseMethod · 0.95
js_dumpsMethod · 0.45

Tested by

no test coverage detected