1from selenium.webdriver.common.action_chains import ActionChains
2
3element = driver.find_element_by_id("my-id")
4
5actions = ActionChains(driver)
6actions.move_to_element(element).perform()
1# this scrolls untill the element is in the middle of the page
2element = driver.find_element_by_id("my-id")
3desired_y = (element.size['height'] / 2) + element.location['y']
4current_y = (driver.execute_script('return window.innerHeight') / 2) + driver.execute_script('return window.pageYOffset')
5scroll_y_by = desired_y - current_y
6driver.execute_script("window.scrollBy(0, arguments[0]);", scroll_y_by)