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

Method scroll_into_view

seleniumbase/fixtures/base_case.py:6945–6958  ·  view source on GitHub ↗

Uses the JS scrollIntoView() method to scroll to an element. Unlike other scroll methods, (which put elements upper-center), this method places elements at the very top of the screen.

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

Source from the content-addressed store, hash-verified

6943 self.slow_scroll_to(selector, by=by, timeout=timeout)
6944
6945 def scroll_into_view(self, selector, by="css selector", timeout=None):
6946 """Uses the JS scrollIntoView() method to scroll to an element.
6947 Unlike other scroll methods, (which put elements upper-center),
6948 this method places elements at the very top of the screen."""
6949 self.__check_scope()
6950 if not timeout:
6951 timeout = settings.SMALL_TIMEOUT
6952 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
6953 timeout = self.__get_new_timeout(timeout)
6954 if self.__is_cdp_swap_needed():
6955 self.cdp.scroll_into_view(selector)
6956 return
6957 element = self.wait_for_element_visible(selector, by, timeout=timeout)
6958 self.execute_script("arguments[0].scrollIntoView();", element)
6959
6960 def scroll_to_top(self):
6961 """Scroll to the top of the page."""

Callers 3

scroll_toMethod · 0.45
slow_scroll_toMethod · 0.45
slow_scroll_to_elementFunction · 0.45

Calls 5

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
execute_scriptMethod · 0.95

Tested by

no test coverage detected