I'm having some trouble scrolling down an infinite scrolling page using Python Selenium. I'd like to scroll down this page so that I can click on to each film on the page. The code runs to the end and quits the driver but without scrolling down the page - what's wrong?
def scroll(driver):
timeout = 5
# Get scroll height
last_height = driver.execute_script("return document.body.scrollHeight")
while True:
# Scroll down to bottom
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
# load the website
time.sleep(5)
# Calculate new scroll height and compare with last scroll height
new_height = driver.execute_script("return document.body.scrollHeight")
driver.get("https://www.justwatch.com/uk/provider/bfi-player/movies")
scroll(driver)
driver.quit()