Clear example of webdriver wait

4,688 views
Skip to first unread message

Danny Guerrier

unread,
Feb 11, 2010, 10:09:50 AM2/11/10
to webd...@googlegroups.com
Does anyone have a clear and working example of how to implement a wait with webdriver?
The past examples make little sense to me.

Thanks

Eran M.

unread,
Feb 11, 2010, 12:47:29 PM2/11/10
to webd...@googlegroups.com
There you go:

    
    ExpectedCondition e = new ExpectedCondition<Boolean>() {
      public Boolean apply(WebDriver d) {
        d.findElement(GwtWebDriverHelper.byGwtLabel("AlertButton"));
        return Boolean.valueOf(true);
      }
    };
    
    Wait w = new WebDriverWait(driver, 15);
    w.until(e);
    
    WebElement clickButton = driver.findElement(GwtWebDriverHelper.byGwtLabel("AlertButton"));


Notice you don't have to catch the NotFoundException yourself, as the until(..) call does it for you.

Eran

--
You received this message because you are subscribed to the Google Groups "webdriver" group.
To post to this group, send email to webd...@googlegroups.com.
To unsubscribe from this group, send email to webdriver+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/webdriver?hl=en.

Danny Guerrier

unread,
Feb 11, 2010, 1:19:05 PM2/11/10
to webd...@googlegroups.com
cool thx

Jessie Morris

unread,
Feb 16, 2010, 5:04:09 PM2/16/10
to webd...@googlegroups.com
Can I get an example of this in Ruby?
--
Jessie Morris
Confetti Antiques & Books
801-380-6820 (Cell)
jes...@confettiantiques.com
http://www.confettiantiques.com

Jari Bakken

unread,
Feb 16, 2010, 6:17:35 PM2/16/10
to webd...@googlegroups.com
On Tue, Feb 16, 2010 at 11:04 PM, Jessie Morris
<jes...@confettiantiques.com> wrote:
> Can I get an example of this in Ruby?
>

We haven't implemented any support classes (like WebDriverWait) for Ruby yet.

Here's one way to do it:

http://gist.github.com/306034

Or perhaps something like

Waiter.new(driver).when_present(:id => "hello") do |element|
...use element...
end

If anyone have opinions on what would be a neat API for this in ruby,
I'd love to hear about it.

Jessie Morris

unread,
Feb 17, 2010, 11:17:17 AM2/17/10
to webd...@googlegroups.com
I like the http://gist.github.com/306034 example. It makes sense and the code is clear. It also allows me to test multiple things at once.

Aaron Tinio

unread,
Mar 26, 2010, 1:09:33 AM3/26/10
to webdriver
Having <code>Wait.while</code> would also be great.
Reply all
Reply to author
Forward
0 new messages