Skip to content
QA Knowledge Hub

TimeoutException in Selenium

Updated 2026-11-13 · 2 min read

A deadline expired, but the exception alone does not identify the slow or impossible step. Separate explicit waits from page-load and script timeouts.

Recognise the error

The official Java API names this exception:

org.openqa.selenium.TimeoutException

This is the documented exception identifier, not a reproduced stack trace. Driver-specific wording and diagnostic details vary. Keep the full message from your own run; no browser error was reproduced for this page. Java fragments below assume an existing Selenium 4 WebDriver driver and standard Selenium imports. They were checked against the APIs but not compiled or run here.

A Selenium command did not finish within its allowed time. The exception alone does not prove the application is slow: a wait for a misspelled ID can never succeed.

The WebDriver specification defines the corresponding protocol error string as:

timeout

An explicit-wait timeout is generated by the language binding; it need not come from a remote protocol error response.

1. The explicit-wait condition cannot become true

Check the locator, current URL and selected frame first. For a booking result, wait for the result the user can actually read rather than merely waiting for any table to exist.

WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
String result = wait.until(ExpectedConditions.visibilityOfElementLocated(
    By.id("booking-result"))).getText();

If the result is inside an iframe, select that frame before this wait. If the previous step redirected to login, fix session setup; extra seconds will not create the booking result.

2. The action completed, but the asserted state is wrong

An API validation failure may leave the form open. Inspect the network response and the visible validation message. Fix test data or the product defect rather than catching the timeout and continuing. For a successful fixture, use an expected text condition:

wait.until(ExpectedConditions.textToBePresentInElementLocated(
    By.id("booking-result"), "Booking confirmed"));

3. The deadline belongs to navigation or a script

A driver.get(...) failure is not controlled by WebDriverWait. Selenium exposes separate settings:

driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(30));
driver.manage().timeouts().scriptTimeout(Duration.ofSeconds(10));

These are example budgets, not recommended service targets. Script timeout applies to asynchronous script execution. A legitimate slow flow may need a larger budget; choose it from the expected behaviour and observed timings.

Prevention and interview answer

Do not mix implicit and explicit waits. Record the failing command, condition, URL, screenshot and elapsed time. “I first identify which clock expired, then establish whether the condition is reachable; I increase a deadline only when the expected flow justifies it.”

Compare a missing element with Playwright locator timeouts.

Quick answers

Is every Selenium timeout an explicit-wait failure?

No. Page loads and asynchronous scripts have separate deadlines too. Read the failing command.

Should I mix implicit and explicit waits?

Avoid mixing them because their interaction can make wait duration difficult to predict.

Sources

Want a project you can show in interviews?

The portfolio project kit walks you through testing a deliberately buggy app with Selenium or Playwright and API tests, then explaining it. The app itself is free.