环境:win7+Eclipse Neon+selenium 2.53
问题一:
selenium无法启动org.openqa.selenium.SessionNotCreatedException:session not created exception
解决方法:
本机的chrome 为61版本,更新chrome driver的版本即可
如果webdriver是用remotedriver实例化(什么意思),则会提示如下错误,排除地址错误或者服务器没有启动的因素,原因跟上面是一样的,更换版本就好了。
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure
问题二:
http://blog.youkuaiyun.com/wlh5520/article/details/31353463
问题三:
现象:出现报错org.openqa.selenium.NoSuchElementException: Unable to locate element
原因:进入网页时,网页可能在loading中,因此找不到元素。
解决方法:你可以让他休眠Thread.sleep(2000),即休眠2秒,应该可以找到元素了。
问题三消失了,引出了问题四
问题四:
Exception in thread "main" org.openqa.selenium.StaleElementReferenceExceptionstale element reference: element is not attached to the page document
这个报错意思是找得到元素,但是它不在当前可见的页面上。可能性很多:
-
上个操作和下个操作间隔时间太短,代码执行速度比页面渲染速度快。
-
分辨率问题,运行环境驱动与调试的驱动不一样。
建议:用try的方法,失败的时候通过webdirver截一下图看是什么情况。
还未解决