Is there a way to scroll down on a page until a certain element pops up ? #2367
-
| As I ask on the title, is there a way to do it? | 
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
| There are several scroll methods that you can work with: self.scroll_to(selector, by="css selector", timeout=None)
# Duplicates: self.scroll_to_element(selector, by="css selector")
self.slow_scroll_to(selector, by="css selector", timeout=None)
# Duplicates: self.slow_scroll_to_element(selector, by="css selector")
self.scroll_into_view(selector, by="css selector", timeout=None)
self.scroll_to_top()
self.scroll_to_bottom()If the element that you want to interact with is already in the html, (but not visible yet), then you can use  from seleniumbase import BaseCase
BaseCase.main(__name__, __file__)
class MyTestClass(BaseCase):
    def test_base(self):
        self.open("URL")
        for i in range(20):
            self.execute_script("window.scrollTo(0, %s);" % (i * 100))
            if self.is_element_visible("SELECTOR"):
                break
            self.sleep(0.1) | 
Beta Was this translation helpful? Give feedback.
There are several scroll methods that you can work with:
If the element that you want to interact with is already in the html, (but not visible yet), then you can use
self.js_click(selector)to click on the hidden element. If that's not enough, you can create a loop where you call one of the scroll methods and then check fo…