(Coordinates are relative to the screen. Not the window.)
(self, selector, timeout=None)
| 1624 | return coordinates |
| 1625 | |
| 1626 | def get_gui_element_rect(self, selector, timeout=None): |
| 1627 | """(Coordinates are relative to the screen. Not the window.)""" |
| 1628 | if not timeout: |
| 1629 | timeout = settings.SMALL_TIMEOUT |
| 1630 | element_rect = self.get_element_rect(selector, timeout=timeout) |
| 1631 | e_width = element_rect["width"] |
| 1632 | e_height = element_rect["height"] |
| 1633 | window_rect = self.get_window_rect() |
| 1634 | w_bottom_y = window_rect["y"] + window_rect["height"] |
| 1635 | viewport_height = window_rect["innerHeight"] |
| 1636 | x = window_rect["x"] + element_rect["x"] |
| 1637 | y = w_bottom_y - viewport_height + element_rect["y"] |
| 1638 | y_scroll_offset = window_rect["pageYOffset"] |
| 1639 | if ( |
| 1640 | hasattr(sb_config, "_cdp_browser") |
| 1641 | and sb_config._cdp_browser == "opera" |
| 1642 | ): |
| 1643 | # Handle special case where Opera side panel shifts coordinates |
| 1644 | x_offset = window_rect["outerWidth"] - window_rect["innerWidth"] |
| 1645 | if x_offset > 56: |
| 1646 | x_offset = 56 |
| 1647 | elif x_offset < 22: |
| 1648 | x_offset = 0 |
| 1649 | x = x + x_offset |
| 1650 | y = y - y_scroll_offset |
| 1651 | x = x + window_rect["scrollX"] |
| 1652 | y = y + window_rect["scrollY"] |
| 1653 | return ({"height": e_height, "width": e_width, "x": x, "y": y}) |
| 1654 | |
| 1655 | def get_gui_element_center(self, selector, timeout=None): |
| 1656 | """(Coordinates are relative to the screen. Not the window.)""" |
no test coverage detected