selenium scroll by specific pixel values
I would use window.scrollBy(x, y)
like this:
#first move to the elementself.driver.execute_script("return arguments[0].scrollIntoView(true);", element)#then scroll by x, y values, in this case 10 pixels upself.driver.execute_script("window.scrollBy(0, -10);")
HERE you will find the documentation on scrollBy
.
to scroll to a specific element on a page:
element = driver.find_element_by_xpath("html/body/div[6]/div[1]/div[2]/a")element.location_once_scrolled_into_view