Slow motion scroll to destination
(self, selector, by="css selector", timeout=None)
| 6902 | self.scroll_to(selector, by=by, timeout=timeout) |
| 6903 | |
| 6904 | def slow_scroll_to(self, selector, by="css selector", timeout=None): |
| 6905 | """Slow motion scroll to destination""" |
| 6906 | self.__check_scope() |
| 6907 | if not timeout: |
| 6908 | timeout = settings.SMALL_TIMEOUT |
| 6909 | if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT: |
| 6910 | timeout = self.__get_new_timeout(timeout) |
| 6911 | original_selector = selector |
| 6912 | original_by = by |
| 6913 | selector, by = self.__recalculate_selector(selector, by) |
| 6914 | if self.__is_cdp_swap_needed() and ":contains(" not in selector: |
| 6915 | self.cdp.scroll_into_view(selector) |
| 6916 | return |
| 6917 | element = self.wait_for_element_visible( |
| 6918 | original_selector, by=original_by, timeout=timeout |
| 6919 | ) |
| 6920 | try: |
| 6921 | if self.browser != "safari": |
| 6922 | scroll_distance = js_utils.get_scroll_distance_to_element( |
| 6923 | self.driver, element |
| 6924 | ) |
| 6925 | if abs(scroll_distance) > constants.Values.SSMD: |
| 6926 | self.__jquery_slow_scroll_to(selector, by) |
| 6927 | else: |
| 6928 | self.__slow_scroll_to_element(element) |
| 6929 | else: |
| 6930 | self.__jquery_slow_scroll_to(selector, by) |
| 6931 | except Exception: |
| 6932 | self.wait_for_ready_state_complete() |
| 6933 | time.sleep(0.12) |
| 6934 | element = self.wait_for_element_visible( |
| 6935 | original_selector, by=original_by, timeout=timeout |
| 6936 | ) |
| 6937 | self.__slow_scroll_to_element(element) |
| 6938 | |
| 6939 | def slow_scroll_to_element( |
| 6940 | self, selector, by="css selector", timeout=None |