[
http://jira.openqa.org/browse/WTR-452?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=19849#action_19849
]
Bret Pettichord commented on WTR-452:
-------------------------------------
Here at Convio, Hugh monkey-patched the wait method to include a time out. Here
is the code, so you can see how it works. (There are other changes in here as
well that I don't really want to discuss right now.)
I find that this timeout feature is a significant benefit to us. You'll see
that here it is hard-coded to 3 minutes.
def wait(no_sleep=false)
# don't wait if there's a modal open
return if @ie.respond_to?('hwnd') && (GetWindow.call(@ie.hwnd,
GW_ENABLEDPOPUP)[0] > 0)
@rexmlDomobject = nil
@down_load_time = 0.0
@polling_sleep = 0.05
start_load_time = Time.now
begin
Timeout::timeout(180) {
begin
until @ie.readyState == READYSTATE_COMPLETE do; sleep
@polling_sleep; end
until @ie.document do; sleep @polling_sleep; end
documents_to_wait_for = [[email protected]]
rescue WIN32OLERuntimeError # IE window must have been closed
@down_load_time = Time.now - start_load_time
return @down_load_time
end
while doc = documents_to_wait_for.shift
begin
until doc.readyState == ("complete" || "interactive") do; sleep
@polling_sleep; end
@url_list << doc.location.href unless
@url_list.include?(doc.location.href)
doc.frames.length.times do |n|
begin
documents_to_wait_for << doc.frames[n.to_s].document
rescue WIN32OLERuntimeError, NoMethodError
end
end
rescue WIN32OLERuntimeError
end
end
}
rescue Timeout::Error
puts "Timed out while waiting for browser to load page: #{url}"
puts @ie.busy.inspect
puts @ie.readyState.inspect
puts
@ie.refresh
end
@down_load_time = Time.now - start_load_time
run_error_checks
sleep @pause_after_wait unless no_sleep
@down_load_time
end
> adding timeout to #wait
> -----------------------
>
> Key: WTR-452
> URL: http://jira.openqa.org/browse/WTR-452
> Project: Watir
> Issue Type: Improvement
> Components: Wait
> Affects Versions: 1.6.5
> Environment: all envs
> Reporter: Jarmo Pertman
>
> Currently it is possible that Watir will block forever in it's #wait method
> under some circumstances. There are questions once in a while in the group
> also about the timeout of Watir.
> Unfortunately currently there is no timeout!
> I have a proposal to add a timeout. And make it hardcoded - let's say 5
> minutes. Why hardcoded? Because i think that if your page is unable to load
> in 5 minutes then your page is broken and should be fixed/changed anyway.
> This would be a small indicator to the developers and testers that they
> shouldn't waste so much time of their lives for waiting some bad application
> to render a page.
> Charley proposed to create an issue and let people to vote (not downvote) it!
> So, what do you guys think about making Watir a little as an Opinionated
> Software as Rails tries to be?
> (PS, if your page loads more than 5 minutes and you cannot get yourself
> together to fix it or tell your developers to fix it and you really need to
> have longer timeouts, then you can always monkey-patch #wait. We're talking
> about Ruby where everything is possible, remember?)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.openqa.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development