Fluent Wait

Click start. The status changes several times before it becomes ready for polling.

Idle

How to test
// Java
driver.findElement(By.id("fluent_start")).click();
Wait<WebDriver> wait = new FluentWait<>(driver)
    .withTimeout(Duration.ofSeconds(8))
    .pollingEvery(Duration.ofMillis(500))
    .ignoring(NoSuchElementException.class);
WebElement status = wait.until(d -> {
    WebElement el = d.findElement(By.id("fluent_status"));
    return "ready".equals(el.getAttribute("data-state")) ? el : null;
});

# Python
driver.find_element(By.ID, "fluent_start").click()
wait = WebDriverWait(driver, 8, poll_frequency=0.5, ignored_exceptions=(NoSuchElementException,))
status = wait.until(lambda d: d.find_element(By.ID, "fluent_status")
                    if d.find_element(By.ID, "fluent_status").get_attribute("data-state") == "ready" else False)

// Java - Full Test
driver.findElement(By.id("fluent_reset")).click();
driver.findElement(By.id("fluent_start")).click();
Wait<WebDriver> wait = new FluentWait<>(driver)
    .withTimeout(Duration.ofSeconds(8))
    .pollingEvery(Duration.ofMillis(500))
    .ignoring(NoSuchElementException.class);
WebElement status = wait.until(d -> {
    WebElement el = d.findElement(By.id("fluent_status"));
    return "ready".equals(el.getAttribute("data-state")) ? el : null;
});
assert status.getText().contains("Ready after fluent polling");
driver.findElement(By.id("fluent_ready_btn")).click();
WebElement result = driver.findElement(By.id("fluent_success"));
assert result.getText().contains("Fluent wait completed");

# Python - Full Test
driver.find_element(By.ID, "fluent_reset").click()
driver.find_element(By.ID, "fluent_start").click()
wait = WebDriverWait(driver, 8, poll_frequency=0.5, ignored_exceptions=(NoSuchElementException,))
def ready_status(driver):
    status = driver.find_element(By.ID, "fluent_status")
    return status if status.get_attribute("data-state") == "ready" else False
status = wait.until(ready_status)
assert "Ready after fluent polling" in status.text
driver.find_element(By.ID, "fluent_ready_btn").click()
result = driver.find_element(By.ID, "fluent_success")
assert "Fluent wait completed" in result.text

// Java - Alternative Solution
driver.findElement(By.id("fluent_start")).click();
new FluentWait<WebDriver>(driver)
    .withTimeout(Duration.ofSeconds(8))
    .pollingEvery(Duration.ofMillis(500))
    .until(d -> "ready".equals(d.findElement(By.id("fluent_status")).getAttribute("data-state")));

# Python - Alternative Solution
driver.find_element(By.ID, "fluent_start").click()
WebDriverWait(driver, 8, poll_frequency=0.5).until(
    lambda d: d.find_element(By.ID, "fluent_status").get_attribute("data-state") == "ready"
)


Tester Task
  1. Click the button with id fluent_start.
  2. Create a fluent wait with an 8 second timeout.
  3. Poll every 500 milliseconds for fluent_status.
  4. Wait until data-state becomes ready.
  5. Verify the status contains Ready after fluent polling.
  6. Click fluent_ready_btn and verify fluent_success is displayed.