Scroll down a div by sending keys

  Kiến thức lập trình

I am trying to scroll down the element with id ‘content’ in this page

I tried –

      element = browser.find_element(By.ID, 'content')
      element.click()
      time.sleep(scroll_pause)
      element.send_keys(Keys.END)

But this fails with “element not interactable” error.

PS1: clicking on the content element and pressing END works on a manually run browser.

PS2:

I tried scrolling without sending keys, with the following:

element_js = "document.getElementById('content')"
browser.execute_script(f"{element_js}.scrollTo(0, {element_js}.scrollHeight);")

But this does not really scroll down the div – just increments scrollHeight.

PS3: I tried looking at similar questions on this site -solutions proposed there don’t work.

LEAVE A COMMENT