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

Method slow_scroll_to

seleniumbase/fixtures/base_case.py:6904–6937  ·  view source on GitHub ↗

Slow motion scroll to destination

(self, selector, by="css selector", timeout=None)

Source from the content-addressed store, hash-verified

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

Callers 4

scroll_toMethod · 0.95
test_dialog_boxesMethod · 0.80

Calls 10

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
scroll_into_viewMethod · 0.45
sleepMethod · 0.45

Tested by 1

test_dialog_boxesMethod · 0.64