使用selenium用xpath获取页面元素遇到的bug以及解决办法

报错如下:
selenium.common.exceptions.StaleElementReferenceException: Message: stale element reference: element is not attached to the page document
原因:页面还没加载完就去获取页面数据,所以获取不到
解决方法:加个time.sleep(3),等几秒后就可以正常使用xpath、selector之类的了

你可能感兴趣的:(python,selenium,bug,测试工具)