Scrolling to top of the page in Python using Selenium
You can simply use CTRL + HOME keys. It will scroll to the top of the page.
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + Keys.HOME)
You can consider to locate the element in the HTML DOM
first, then we can scroll
the element into the Viewport
as follows:
element = driver.find_element_by_xpath("element_xpath")
self.driver.execute_script("return arguments[0].scrollIntoView(true);", element)
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
driver.get("__")
#to scroll try use the following command
driver.execute_script("scrollBy(0,250);")
It will work !!