我的兩個方案的結果 -結合隱含的等待和明確的等待一起意外的等待時間
1)首先
@driver.manage.timeouts.implicit_wait = 30
@wait = Selenium::WebDriver::Wait.new(:timeout => 45) # Time greater than implicit
@wait.until {@driver.find_element(:tag_name => "body").text.include?("hey")}
這給司機45秒搜索的文本(預計)
2)其次
@driver.manage.timeouts.implicit_wait = 30
@wait = Selenium::WebDriver::Wait.new(:timeout => 5) # Time less than implicit
@wait.until {@driver.find_element(:tag_name => "body").text.include?("hey")}
現在,這爲駕駛員提供了30秒尋找文本(不是預期的)
有沒有辦法讓硒等待時間只有explicit
而不是兩個更大的等待時間?
注 - 不聲明隱含的等待時間不是一個選項,因爲我不能讓selenium掛起每次司機無法找到的東西。
使用Selenium版本30,窗戶,FF
根據隱式等待文檔,默認設置爲0,那麼究竟是什麼問題呢? – phoet 2013-03-01 21:41:27
爲什麼不把隱式等待設置爲5呢? – BlackHatSamurai 2013-03-01 23:51:53
隱式等待可以幫助我對每個元素保持默認的等待狀態,所以不希望保持低至5秒。我想用更短的時間等待(比如說「wait_to_fail」)來檢查元素*不存在。 – Amey 2013-03-03 11:37:00