java + Selenium:stale element reference: element is not attached to the page document页面刷新或返回元素失效问题解决

1.前言

前面有一篇帖子写了一些关于论坛水帖的东西

java + selenium 实现QQ快速安全登录xx论坛

使用selenium登陆只是实现了第一步,然鹅,实现放水的路还有很远

接下来解决一个小白很容易出现也很困惑的问题,就是标题所提示的异常信息

org.openqa.selenium.StaleElementReferenceException: stale element reference: element is not attached to the page document
stale element reference: element is not attached to the page document
  (Session info: chrome=47.0.2526.106)
  (Driver info: chromedriver=2.20.353145 (343b531d31eeb933ec778dbcf7081628a1396067),platform=Windows NT 6.3 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 137 milliseconds
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '2.48.2', revision: '41bccdd10cf2c0560f637404c2d96164b67d9d67', time: '2015-10-09 13:08:06'
System info: host: '7YYCXY1', ip: '10.101.121.23', os.name: 'Windo

你可能感兴趣的:(#,Java,+,Selenium)