2013-04-03 130 views
0

我使用的是坦誠,黃瓜來測試我的iOS應用,並已遇到一些問題時,我的測試是以下形式的弗蘭克黃瓜測試用例掛起當使用「當我等待」測試

When I wait to see "OpenButton" 

如果帶有可訪問性標籤「OpenButton」的UIView從未出現,而不是在WAIT_TIMEOUT命中後超時並報告測試錯誤,黃瓜只是掛起。

因爲我沒有看到WAIT_TIMEOUT甚至在core_frank_steps.rb中使用,我不知道這是爲什麼任何形式的「當我等待..」的測試用例只會掛起的原因。

注:core_frank_steps.rb可以發現here

回答

1
# Polls every 0.1s , returns true when element is present 
# @param selector [String] Frankly selector e.g. view marked:'' 
# @param timeout [Int] seconds to wait 
def wait_for_element(selector, timeout=10) 

    #the return value of the yield expression isn't working, so we use a closure 
    res = nil 
    wait_until(:timeout => timeout, :message => "Waited for element #{selector} to exist") { 
    res = element_exists(selector) 
    } 
    res 
end 

上述功能幫助我們避開一些這樣的等待場景。