使用ruby webdriver获取到达的文件结束(EOFError)



我的一些测试通过了一次,然后失败了,"到达文件结束(EOFError)"。不知道是什么导致了这个一致性问题。有时它会在填写表格时出错。当点击按钮时,它会失败。

使用以下语句:OSX 10.9.3Watir-webdriver 0.6.10Ruby 1.9.3Chrome 35.0Chromedriver

不确定问题是什么,但一个简单的工作来摆脱这个错误是使用开始/救援语句周围的代码,导致这个错误(检查哪行号终端输出说导致错误)。

例如:

browser.close #This is the line giving the EOFError

执行以下操作:

begin
    browser.close #if there is an error: jump to the rescue statement
rescue
    #don't put any code in the rescue statement (ignore the error)
end
#rest of code

begin/rescue语句的工作方式是,如果begin语句中的代码导致错误,它将运行rescue语句中的代码。在这种情况下,由于救援语句中没有任何代码,因此它只会忽略错误并继续执行其余代码。

最新更新