Home > Net >  how to scroll a local div element with selenium
how to scroll a local div element with selenium

Time:05-16

I am trying to scroll through a local div element using driver.find_element_by_xpath(element).send_keys(Keys.PAGE_DOWN)

the problem is that element is not an element that accepts key input, so the code throws an selenium.common.exceptions.ElementNotInteractableException: Message: element not interactable

i could rather use pyautogui to simulate mouse and keyboard functions

pyautogui.moveTo(663,680)
pyautogui.click(663,680)

pyautogui.scroll(-200)
time.sleep(2)

but i would like to keep the code inside of the browser

any solution?

CodePudding user response:

driver.execute_script("arguments[0].scrollIntoView(true)", element)
  • Related