Selenium + Java · Lesson 25 of 44
Module 25: Waits
Your task
Implement waitForElementClickable:
Write it in the editor, then press Check answer (Ctrl + Enter).
elementToBeClickable).import org.openqa.selenium.support.ui.WebDriverWait;
import org.openqa.selenium.support.ui.ExpectedConditions;
import java.time.Duration;
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
// Wait until visible:
WebElement banner = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("banner")));
// Wait until clickable:
WebElement submitBtn = wait.until(ExpectedConditions.elementToBeClickable(By.id("submit-btn")));
submitBtn.click();Welcome to Phase 4! Synchronization is the single most critical factor for reliable Selenium tests. In this lesson, we break down why Thread.sleep is forbidden, how Implicit wait causes hidden delays, and how to master WebDriverWait with ExpectedConditions. Let's master waits!
Part of the Selenium + Java course (Selenium with Java). Practice this concept live in the Selenium Online Compiler or explore our free automation practice form.
Never mix them! The Selenium official documentation explicitly warns that mixing implicit and explicit waits can result in unpredictable timeout spikes.
Ready? Solve the task in the editor
Use Check answer to mark it complete. Hints are there if you need them.
___