Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

On my page under test, after an AJAX request completes, one of three divs with a specific message will become visible. Their immediate parent is already considered visible. If I don't know in advance which one it will be (because I'm writing a utility function on a PageObject), is there some way I can use implicit waits to wait for the AJAX?

The page has something like:

<div id="IAmConsideredVisibleAlready">
    <div id="successMessage" style="display: none">AJAX returned successfully </div>
    <div id="error1" style="display: none">AJAX had error number 1</div>
    <div id="error2" style="display: none">AJAX had error number 2</div>

And my code is basically:

public boolean entryProducesSuccessMessage(String entry) throws Exception {

    //Wait goes here:
    //Webdriver.wait(driver, 500).until(one of the three divs is present)

    if (successMessage.isDisplayed()) return true;
    else if (error1.isDisplayed()) return false;
    else if (error2.isDisplayed()) return false;

    throw new Exception("Could not determine if an error occurred.");
share|improve this question
I'm not a Webdriver user, but if you can count the number of visible children in the parent div, you should be able to run an implicit wait until the parent's child count increases. Something along the line of wait.until (IAmConsideredVisibleAlready.Children.Count() == 1) should be possible. –  Kate Paulk Apr 24 '14 at 11:22
Look into FluentWait –  Ant's Aug 1 '14 at 2:13
@Yamikuronue did you ever solve this? If so, would you mind jotting down an answer? –  user246 Apr 18 at 13:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.