这是怎么回事?我想等待下一个任务,直到我的页面完全加载。问题:没有错误,但驱动程序不等待:-(
# wait for page load
wait2 = Selenium::WebDriver::Wait.new(:timeout => 20) # seconds
count = 0
begin
raise("maximum attempt crossed #{count} times") if count > 3
wait2.until {
self.getDriver.execute_script("return document.readyState;") == "complete"
}
rescue Timeout::Error
count +=1
retry
end
#do sth发布于 2013-10-31 23:58:09
我将按如下方式处理此问题:
wait = Selenium::WebDriver::Wait.new(:timeout => 20) # seconds
count = 0
begin
raise("maximum attempt crossed #{count} times") if count > 3
# if the page having title 'page_title' is not loaded within 20 seconds
# time out error will be thrown,which will be handled by the rescue clause.
wait.until { driver.title == 'page_title' }
rescue Timeout::Error
count +=1
retry
end发布于 2015-06-18 10:38:19
这似乎对我很有效。
DEFAULT_TIMEOUT = 10
def wait_for_page_to_load(options = {})
options[:timeout] ||= DEFAULT_TIMEOUT
wait = Selenium::WebDriver::Wait.new(options)
wait.until {current_driver.execute_script('var browserState = document.readyState; return browserState;') == "complete" }
endhttps://stackoverflow.com/questions/19711118
复制相似问题