History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: WTR-166
Type: New Feature New Feature
Status: Open Open
Priority: Major Major
Assignee: Unassigned
Reporter: Jeff Fry
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Watir

Wait for XHRs and timers to complete before considering the page loaded (either as a configurable option or always on)

Created: 21/Jun/07 04:30 PM   Updated: 14/Oct/07 11:00 AM
Component/s: None
Affects Version/s: 1.5.0/1.5.1
Fix Version/s: Future

Original Estimate: Unknown Remaining Estimate: Unknown Time Spent: Unknown


 Description  « Hide
Watir.wait() listens to whether IE thinks its done loading, and then checks to see that the main document and any sub documents/frames have finished loading. More and more, there are pages that on load also kick off various XHRs and timers. For me - and possibly for a growing number of folks, testing more AJAXy applications - it would be great to expand wait() to check if there are any XHRs or timers pending, in additional to the checks it currently makes.

Note, I don't know, but there may be applications where an XHR is intentionally left open at all times. If this happens I would guess that it's rare, but if we change the default behavior of watir.wait() to wait for pending XHRs and timers, we might want to give a config option that turns this off as well.

 All   Comments   Work Log   Change History      Sort Order:
Jeff Fry - 24/Aug/07 10:22 AM
Here's a failing test for this issue. Please let me know if you have any questions, or if I can help make this happen.

require 'test/unit'
require 'watir'

class TC_one_topic < Test::Unit::TestCase
  
  # Load one page. Test if wait() waits for XHRs and Timers.
  def test_xhr_loaded
    @urlRoot = 'http://sandbox.freebase.com' # test server
    @ie = Watir::IE.new
    @ie.set_fast_speed
    
    @ie.goto(@urlRoot+'/view/kevin_bacon') #Kevin Bacon
    #enabling this makes the test pass.
    #while !@ie.link(:text,'United States').exists?
    # sleep 1
    #end
    assert(@ie.link(:text,'United States').exists?)
  end #test_xhr_loaded
  
end #class

Bret Pettichord - 14/Oct/07 12:33 AM
Do you know how we can tell whether any XHR's are still open?

Jeff Fry - 14/Oct/07 11:00 AM
I don't...and have heard folks say it may in fact not be possible, unless the application under test chooses to announce them. It's quite possible that the only way to get around this include some expected code we'll look for, for example:
  "if ie.wait sees that X is set to False, it'll keep waiting until wait X is set to True."

That still requires folks to make (or request) changes to the application under test, but it gives us a ready-made recipe that they can follow and means they don't have to override ie.wait.