At 10:21 AM 9/27/2005, Sean Gallagher wrote:
>I am looking to test updates to the page from the Ajax engine. In the case
>of instant search, I need to be able to test that when I type "ruby" into
>the form field, the browser is updated and shows the link for "Ruby Home
>Page" without clicking the button and submitting the form. (try typing that
>manually in the browser and you will see what I mean)

This works:

   require 'watir'
   ie = Watir::IE.start("http://instant.search.yahoo.com";)
   ie.text_field(:name, 'p').set('ruby')
   while ! ie.link(:id, 'yschakis').exists? do sleep 0.1; end
   puts ie.link(:id, 'yschakis').text

Watir assumes that certain commands will trigger a traditional http 
request/response process and accordingly will automatically wait for the 
browser to complete loading a new page. These assumptions don't work with 
Ajax. Thus Ajax scripts must explicitly include code for synchronization. 
(That's what the 'while' statement does.)

Watir could be modified to have calls like ie.link(:id, 'yschakis') 
automatically include this kind of synchronization (also adding a timeout 
if the object didn't appear in a certain amount of time). This would make 
ajax scripting easier. And it's arguably a more reliable model in general 
that the current heuristics. With JavaScript, any event could end up 
triggering a page request.

Bret


_____________________
  Bret Pettichord
  www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to