[PYTHON] An alternative if Selenium's bottom scroll command (window.scrollTo) doesn't work
Overview
- As for how to scroll to the bottom of the page, if you google, the information of "window.scrollTo" will be returned.
- However, depending on the site, scrolling at the bottom of the page by Selenium does not work for some reason.
- In that case, you can scroll down by clicking and key input at the page down, so I will summarize it in this article.
Method
How to scroll the bottom that didn't work (at a certain site)
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
How it worked
#I clicked once and then page down and I was able to scroll
#PAGE if you want to scroll to the bottom_Repeat DOWN
driver.find_element_by_tag_name('body').click()
driver.find_element_by_tag_name('body').send_keys(Keys.PAGE_DOWN)
Finally
- There are differences in movement depending on the site, so I think that you will try various methods.
- This time, it doesn't work unless I click () before PAGE_DOWN, and I struggled until I found that the method of clicking once was effective.