Fast scroll to destination
(self, selector, by="css selector", timeout=None)
| 6872 | time.sleep(0.1) |
| 6873 | |
| 6874 | def scroll_to(self, selector, by="css selector", timeout=None): |
| 6875 | """Fast scroll to destination""" |
| 6876 | self.__check_scope() |
| 6877 | if not timeout: |
| 6878 | timeout = settings.SMALL_TIMEOUT |
| 6879 | if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT: |
| 6880 | timeout = self.__get_new_timeout(timeout) |
| 6881 | if self.__is_cdp_swap_needed(): |
| 6882 | self.cdp.scroll_into_view(selector) |
| 6883 | return |
| 6884 | if self.demo_mode or self.slow_mode: |
| 6885 | self.slow_scroll_to(selector, by=by, timeout=timeout) |
| 6886 | return |
| 6887 | element = self.wait_for_element_visible( |
| 6888 | selector, by=by, timeout=timeout |
| 6889 | ) |
| 6890 | try: |
| 6891 | self.__scroll_to_element(element, selector, by) |
| 6892 | except (Stale_Exception, ENI_Exception): |
| 6893 | self.wait_for_ready_state_complete() |
| 6894 | time.sleep(0.12) |
| 6895 | element = self.wait_for_element_visible( |
| 6896 | selector, by=by, timeout=timeout |
| 6897 | ) |
| 6898 | self.__scroll_to_element(element, selector, by) |
| 6899 | |
| 6900 | def scroll_to_element(self, selector, by="css selector", timeout=None): |
| 6901 | """Same as self.scroll_to()""" |