簡體   English   中英

使用ruby webdriver到達文件結尾(EOFError)

[英]Getting end of file reached (EOFError) using ruby webdriver

我的某些測試通過了一次,然后失敗,並顯示“文件已到達結尾(EOFError)”。 無法找出導致此一致性問題的原因。 有時在填寫表格時會失敗。 有時,單擊按鈕時失敗。

使用以下命令:OSX 10.9.3 Watir-webdriver 0.6.10 Ruby 1.9.3 Chrome 35.0 Chromedriver ChromeDriver v2.10

不確定是什么問題,但是要解決此錯誤,一個簡單的解決方法是在引起該錯誤的代碼周圍使用Begin / Rescue語句(檢查終端輸出說出的行號導致了該錯誤)。

例如:

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語句中的代碼導致錯誤,它將運行急救語句中的代碼。 在這種情況下,由於救援語句中沒有任何代碼,因此它將僅忽略該錯誤並繼續其余代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM