Skip to content

wait until not waiting for ExpectedConditions.presenceOfNestedElementsLocatedBy #3214

@chris-orchard

Description

@chris-orchard

Meta -

OS: Windows 7 Professional
Selenium Version: 2.53.0
Browser: Chrome 54.0.2840.99 m

I have the following Java code:

// wait is an instance of WebDriverWait already declared elsewhere
final List<WebElement> colMatches = wait.until(ExpectedConditions.presenceOfNestedElementsLocatedBy(By.name("Person Results"), By.xpath(".//td[contains(@class, 'dgrid-column-1') and @role='gridcell' and @data-label='Person Name']")));
final WebElement firstRowPersonName = colMatches.get(0);

Expected Behavior -

The first lines should wait until it finds elements within the element located by name("Person Results") that match the xpath condition, or the wait timeout is reached.

The elements that will match are loaded into the results table dynamically by the test.

Actual Behavior -

The wait returns straight away before the matching elements have appeared. The 2nd line therefore gives:

java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

This seems to show that the wait until is not actually waiting as it should. If I set a breakpoint on the 2nd line, wait a few seconds, then re-evaluate the first line it finds the expected elements and prevents the error which confirms my locators are correct, it's just not finding anything matching yet when it is run so my understanding is it should be waiting until it does.

Steps to reproduce -

I'm not sure how to provided a SSCCE for this as the system I'm testing is not available externally. Are there any existing examples on https://jsfiddle.net/ that do something similar that I could modify: load some results with a delay before trying to locate them with an ExpectedConditions.presenceOfNestedElementsLocatedBy?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions