Skip to content

[🐛 Bug]: Some of ExpectedConditions do not wait for the condition #16819

@asolntsev

Description

@asolntsev

Description

Selenium Java binding has a bunch of built-in checks: ExpectedConditions.
They are meant to wait for some time until the desired condition is met.

I found that some of these conditions do not wait. Instead, they throw an exception right away. :(
This is clearly a bug.

Reproducible Code

Given "waiter" with timeout 5 seconds

FluentWait<WebDriver> wait = new FluentWait<>(driver)
  .withTimeout(ofSeconds(5))

and an element that appears after ~2 seconds:

  <div id="slow-cow" value="cow-123">Moooooooo</div>

These checks should wait for ~2 seconds and complete successfully:

wait.until(presenceOfElementLocated(By.cssSelector("#slow-cow")));
wait.until(textToBePresentInElementLocated(slow, "Moooooooo"));
wait.until(textToBePresentInElementValue(slow, "cow-123"));
wait.until(elementToBeSelected(slow));
wait.until(elementSelectionStateToBe(slow, true));
wait.until(attributeToBe(slow, "value", "cow-123"));
wait.until(attributeContains(slow, "value", "cow-123"));
wait.until(presenceOfNestedElementLocatedBy(By.cssSelector("body"), slow));
wait.until(presenceOfNestedElementLocatedBy(driver.findElement(By.cssSelector("body")), slow));
wait.until(frameToBeAvailableAndSwitchToIt(By.id("slow-frame"))); // throws NoSuchElementException without waiting

But all they just throw immediately NoSuchElementException without any waiting. :(

Metadata

Metadata

Assignees

Labels

B-supportIssue or PR related to support classesC-javaJava BindingsI-defectSomething is not working as intended

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions