设置下一页.click()后 运行程序报错如下:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
可能是因为页面还没加载好就点击下一页了,就会报错。
解决办法:在下一页.click()后 设置time.sleep(a) a>=3秒吧。有足够时间加载后再点击页面就没问题了。
另一种等待页面加载好或者最长等待时间的方法(driver=webdriver.Chrome()):driver.implicitly_wait(10)