你可以使用
driver.execute_script("window.scrollTo(0, Y)")
其中Y是高度(在全高清显示器上为1080)。
你也可以使用
driver.execute_script("window.scrollTo(0, document.body.scrollHeight);")
如果你想滚动到无限加载的页面,例如社交网络页面,facebook等
SCROLL_PAUSE_TIME = 0.5# Get scroll heightlast_height = driver.execute_script("return document.body.scrollHeight")while True: # Scroll down to bottom driver.execute_script("window.scrollTo(0, document.body.scrollHeight);") # Wait to load page time.sleep(SCROLL_PAUSE_TIME) # Calculate new scroll height and compare with last scroll height new_height = driver.execute_script("return document.body.scrollHeight") if new_height == last_height: break last_height = new_height
另一种方法是,选择一个对象,然后
label.sendKeys(Keys.PAGE_DOWN);
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)