N NextGen Virtual Academy
AD Administrator Learning Manager
SELENIUM WEBDRIVER · PRACTICE LAB

Selenium Waits

Learn how Selenium waits for web elements and conditions before performing automation actions.

LAB WAIT
OBJECTIVE

What You Will Practice

  • Understand why waits are required.
  • Practice delayed elements.
  • Understand Implicit Wait.
  • Understand Explicit Wait.
  • Understand Fluent Wait.
  • Practice timeout behaviour.
  • Understand polling.
  • Select the correct wait strategy.
01

Implicit Wait

The browser waits for an element to become available before throwing a NoSuchElementException.

IMPLICIT
Element will appear after 3 seconds...
Selenium Java driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
02

Explicit Wait

Wait for a specific condition before continuing the automation script.

EXPLICIT
Waiting for condition...
Selenium Java WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
wait.until(ExpectedConditions.elementToBeClickable(element));
03

Fluent Wait

Configure timeout, polling interval and ignored exceptions.

FLUENT
Polling for element...
Poll Count: 0
Selenium Java Wait<WebDriver> wait = new FluentWait<>(driver)
.withTimeout(Duration.ofSeconds(15))
.pollingEvery(Duration.ofSeconds(2))
.ignoring(NoSuchElementException.class);
04

Timeout Handling

Understand what happens when an expected element does not appear.

TIMEOUT
Selenium Concept wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
05

Choose the Correct Wait

Select the most appropriate wait strategy for each scenario.

CHALLENGE

Scenario 1

You want Selenium to wait globally for elements throughout the application.

Scenario 2

You need to wait until a specific button becomes clickable.

Scenario 3

You need custom polling and exception handling.

QUICK REFERENCE

Selenium Waits

Implicit Wait
driver.manage()
    .timeouts()
    .implicitlyWait(
        Duration.ofSeconds(10)
    );
Explicit Wait
WebDriverWait wait =
    new WebDriverWait(
        driver,
        Duration.ofSeconds(10)
    );
Expected Condition
wait.until(
    ExpectedConditions
    .elementToBeClickable(
        element
    )
);
Fluent Wait
new FluentWait<WebDriver>(
    driver
)
.withTimeout(...)
.pollingEvery(...)
.ignoring(...);