dang, I thought I had fixed this sort of thing, in firefox anyway. I updated firefox's #wait method to keep track of active connections that a page made and wait until they were all complete, which should theoretically make it work for ajax. Is this a problem in both IE and FF, or just FF?
in case the javascript stuff that's going on isn't waiting for a server, though, I don't think there is any way to determine if javascript is running / wait for it.
Vapir does have a slightly nicer way to deal with waiting for an element, with an improved Waiter class (in my opinion anyway). Instead of something like
div=ie.div(:id, 'foo')
Watir::Waiter.wait_until { div.exists? }
you can do:
div=::Waiter.try_for(8) { ie.div?(:id, foo) }
the #div? method is like the usual #div, but method returns nil if the div doesn't exist, and #try_for returns the result of the block, so you can do the whole thing in one line. the 8 is the number of seconds to wait.
I'm also thinking of adding another container method that will automatically wait. Something like
ie.wait_div(:id, 'foo')
which will return that div once it exists, or raise a timeout exception if it doesn't exist after some interval. That seems like something that would be increasingly useful, with all the ajax coming into prevalence these days.
-Ethan