Home > Back-end >  How to scroll element with Selenium?
How to scroll element with Selenium?

Time:06-27

how to scroll a certain page element, not the page itself, but the element, there is a list that is updated dynamically and to get all its elements I need to scroll it to the end

CodePudding user response:

You can use

org.openqa.selenium.interactions.Actions
from selenium.webdriver.common.action_chains import ActionChains

element = driver.find_element_by_id("my-id")

actions = ActionChains(driver)
actions.move_to_element(element).perform()

OR

driver.execute_script("arguments[0].scrollIntoView();", element)

If you wan to scroll to the end of the page then the easiest way is to select a label and then send:

label.sendKeys(Keys.PAGE_DOWN);

OR

label.send_keys(Keys.END)

Hope this answer

  • Related