How to scroll to the end of the page using selenium in Python?
Well I finally figured out a solution:
lenOfPage = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
match=False
while(match==False):
lastCount = lenOfPage
time.sleep(3)
lenOfPage = driver.execute_script("window.scrollTo(0, document.body.scrollHeight);var lenOfPage=document.body.scrollHeight;return lenOfPage;")
if lastCount==lenOfPage:
match=True
This can be done in one line by scrolling to document.body.scrollHeight
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")