Skip to content

Instantly share code, notes, and snippets.

@danyashorokh
Last active October 5, 2017 09:02
Show Gist options
  • Save danyashorokh/0a20767b4edd6705a3cd6b45cb383ed2 to your computer and use it in GitHub Desktop.
Save danyashorokh/0a20767b4edd6705a3cd6b45cb383ed2 to your computer and use it in GitHub Desktop.
[Python] [Selenium] Scrolling to element
def scroll_to(driver, type ,path):
if type == "xpath":
elem = driver.find_element_by_xpath(path)
if type == "id":
elem = driver.find_element_by_css_selector(path)
loc = elem.location
point = "window.scrollTo(0, "+str(loc["y"])+")"
driver.execute_script(point)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment