Answers for "how to scroll till mentioned height in selenium python"

2

selenium scroll to element python

# this scrolls untill the element is in the middle of the page
element = driver.find_element_by_id("my-id")
desired_y = (element.size['height'] / 2) + element.location['y']
current_y = (driver.execute_script('return window.innerHeight') / 2) + driver.execute_script('return window.pageYOffset')
scroll_y_by = desired_y - current_y
driver.execute_script("window.scrollBy(0, arguments[0]);", scroll_y_by)
Posted by: Guest on May-26-2020

Code answers related to "how to scroll till mentioned height in selenium python"

Python Answers by Framework

Browse Popular Code Answers by Language