There is another option to scroll page to required element if element has "id"
attribute
If you want to navigate to page and scroll down to element with @id
, it can be done automatically by adding #element_id
to URL...
Example
Let's say we need to navigate to Selenium Waits documentation and scroll page down to "Implicit Wait" section. We can do
driver.get('https://selenium-python.readthedocs.io/waits.html')
and add code for scrolling...OR use
driver.get('https://selenium-python.readthedocs.io/waits.html#implicit-waits')
to navigate to page AND scroll page automatically to element with id="implicit-waits"
(<div class="section" id="implicit-waits">...</div>
)