For this type of thing we wrapped the WATIR functions that cause AJAX events to fire in our app - set, click, clear, etc with a method that looks for a standard empty div we toss on the page when we are processing these events. This works well enough as things can get added or removed to the DOM and your code doesn't really care what they are until you do an assertion. A much better approach would have been for us to use the add_checker functionality in WATIR to do the same thing. You're definitely already aware of this way of doing things but I thought I would type it out anyway. I don't know currently of any fancy way for WATIR to do this automatically.
Initially I thought you were talking about something else that I was seeing where there appears to be some sort of timing issue where the page reports as being loaded but assert_exists seems to (very very rarely) randomly throw. I need to track this down a little more but I found adding a little bit of polling time and retrying the locate method inside assert_exists seemed to make that problem disappear. I will try to figure it out a little more and get a reproducible test. --brett On Mon, Oct 18, 2010 at 1:10 PM, Jarmo <[email protected]> wrote: > Jari: does that implicit wait in WD mean that 1.5 seconds is waited > everytime before throwing out an Exception? This is not what i'd want. > > After giving some more thought about it then i cannot see any perfect > solution to it and i'm starting to believe that there are none :( > > To give you a better picture of the current situation then this is > what i have to do currently in my tests for example: > button.click > # some javascript work > wait_until {div.exists?) > > button.click > # some javascript work > wait_until {div.visible?} > > button.click > # some javascript work > wait_until {div.text == "expected text"} > > button.click > # some javascript work > wait_until {not div.exists?} > > And i would like to do these examples like this with RSpec: > button.click > # some javascript work > div.should exist > > button.click > # some javascript work > div.should be_visible > > button.click > # some javascript work > div.text.should == "expected text" > > button.click > # some javascript work > div.should_not exist > > In other words i wouldn't want to use any wait_until's or similar > methods explicitly. And considering the examples above it seems to be > impossible to achieve without changing something very drastically or > changing Watir AND RSpec together. > > If you think about it then manual tester also waits something to > happen, implicitly, but (s)he always (well, almost always) knows what > to wait. (S)He also knows if there should something to disappear > instead and waits for it. So if we could build some mind-reading AI > then Watir would rock. > > Ethan: what would you do in #initialize? As you can see from the > examples above then you cannot just wait until element exists - what > if i want to wait until it doesn't exist? That's the problem. Also, i > wouldn't want it to be limited to only "exists?" as written above. > > Bret: using Jari's #while_present doesn't help either because it is > just in a matter of different syntax. > > In short, unless someone comes up with some fantastic idea, then this > thing will be on hold. > > I'd like to see what Ethan (or anyone else) comes up with. > > Jarmo > > On Mon, Oct 18, 2010 at 4:35 AM, Bret Pettichord <[email protected]> > wrote: > > Yes, it could be dangerous feature. Many of the commercial tools added > > something like this without careful thought and as a result completely > > killed the performance of scripts. > > > > Several years ago we had several people tell us that Watir was 20 times > > faster than their Silk tests. I believe it was because Silk added some > > implicit, ubiquitous waiting without much care. > > > > Bret > > > > On Sun, Oct 17, 2010 at 8:24 PM, Jari Bakken <[email protected]> > wrote: > >> > >> On Sun, Oct 17, 2010 at 2:11 PM, Jarmo <[email protected]> wrote: > >> > > >> > What do you guys think? Is there any reason why not to implement > >> > something like that? > >> > > >> > >> WebDriver got this feature recently, configurable as: > >> > >> driver.manage.timeouts.implicit_wait = 1.5 # seconds > >> > >> The default is not to wait at all. Capybara has its own implicit > >> waiting turned on by default (not sure how long). > >> Personally I'm a bigger fan of explicitly waiting where it's needed, > >> but I can see that this is a useful feature. > >> _______________________________________________ > >> Wtr-development mailing list > >> [email protected] > >> http://rubyforge.org/mailman/listinfo/wtr-development > > > > > > > > -- > > Bret Pettichord > > Lead Developer, Watir, www.watir.com > > > > Blog, www.io.com/~wazmo/blog <http://www.io.com/%7Ewazmo/blog> > > Twitter, www.twitter.com/bpettichord > > > > > > _______________________________________________ > > Wtr-development mailing list > > [email protected] > > http://rubyforge.org/mailman/listinfo/wtr-development > > > _______________________________________________ > Wtr-development mailing list > [email protected] > http://rubyforge.org/mailman/listinfo/wtr-development >
_______________________________________________ Wtr-development mailing list [email protected] http://rubyforge.org/mailman/listinfo/wtr-development
