Hi Aiman,
Our aim with webdriver is to present a "blocking api". That is, every
call you make should block until the page has finished loading. There
are some cases (such as an AJAX call) where this isn't possible, and
in those cases, I like to use an extra layer of abstraction: the Page
Object. This is documented on the wiki:
http://code.google.com/p/webdriver/wiki/PageObjects
A quick example of how to use it (with the AJAX wait built in, but not
actually necessary in this case) written off the top of my head:
public class Google {
@FindBy(how = How.NAME, using = "q")
private WebElement oneBox;
public Google(WebDriver driver) {
// Wait 5 seconds for the element to appear
PageFactory.initElements(new AjaxElementLocatorFactory(driver, 5), this);
}
public void searchFor(String query) {
oneBox.clear();
oneBox.sendKeys(query);
oneBox.submit();
}
}
The key line is the one where we use the PageFactory to initialise the
fields on the class.
I'm happy to explain in more detail (or in a different way) if that
would help you more!
Regards,
Simon
On Wed, Jan 21, 2009 at 9:45 PM, Aiman Alsari <
aiman....@gmail.com> wrote:
>
> Hi guys,
>
> I have used Selenium quite extensively in the past and in Selenium
> there is a waitForPageToLoad() method that can be used to block until
> the browser has finished loading. I notice that in WebDriver this
> seems to be implemented when doing an element.click() or driver.get
> (url).
>
> However, I've had problems with random failures, and it seems to be a
> problem related to webdriver not waiting for a page to load. In my
> case its when I call setSelected on a drop down option. Is there
> actually a way to wait for the page to load after any arbitrary
> operation on an element or is it only done on clicks?
>
> Cheers,
> Aiman
> >
>