美文网首页
使用robot framework + selenium2 出现

使用robot framework + selenium2 出现

作者: risalin | 来源:发表于2017-02-06 16:08 被阅读0次

1、出现Stale Element Reference Exception

官方解释说这种异常有两种可能:找元素后对元素进行操作时,元素已经被删除或者元素不再附加到DOM。

一般都是由于JavaScript操作元素导致元素陈旧。

我的项目中需要判断某个元素是否可见,是否hidden,如果不是hidden需要等待,但是由于页面刷新,会导致经常出现此异常。

尝试了很多解决方法:

1) 使用execute JavaScript : return $("#XXX").is(":hidden");  + Wait Until Keyword Succeeds

    这种方法有时会报JavaScript Error

2) 使用 Wait Until Element Is Not Visible    id=XXX

    这种方法会报Stale Element Reference Exception

3) 最后使用 Wait For Condition          return $("#J_LoadPage").is(":hidden");

    似乎可以成功

2、Jenkins + Selenium + IE 出现 WebDriverException: Message: Failed to navigate tohttp://xxxx/x. This usually means that a call to the COM method IWebBrowser2::Navigate2() failed.

这是由于用作Jenkins slave的那台机器,将启动slave的服务作为了windows服务自启动了,同时又从jenkins上执行了本机的ie自动化,可能有冲突,ie总是无法成功执行。

解决方法:

1)去掉windows服务,改用java命令行或者客服端,但是这样的话就无法开机自启动

2)使用selenium-grid,ie连接一个hub,启动浏览器时使用remote-url就行,这样就不会有冲突了

相关文章

网友评论

      本文标题:使用robot framework + selenium2 出现

      本文链接:https://www.haomeiwen.com/subject/zqdpbttx.html