我将为此提供Python代码。我认为翻译成Java很容易:
def scroll_down(self): """A method for scrolling the page.""" # Get scroll height. last_height = self.driver.execute_script("return document.body.scrollHeight") while True: # Scroll down to the bottom. self.driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") # Wait to load the page. time.sleep(2) # Calculate new scroll height and compare with last scroll height. new_height = self.driver.execute_script("return document.body.scrollHeight") if new_height == last_height: break last_height = new_height希望对您有帮助!



