selenium icon indicating copy to clipboard operation
selenium copied to clipboard

[šŸš€ Feature]: Better Logging and Debug Info for WebDriver Wait Failures

Open ceekay10 opened this issue 6 months ago • 5 comments

Description

Feature Request: Improve WebDriverWait TimeoutException Message with Detailed Context

Context

Given that WebDriverWaitis heavily relied upon for synchronisation and a wait condition fails, the resultingTimeoutException` often lacks sufficient context to understand what exactly went wrong. This slows down root cause analysis during triaging.

Suggestion

It would be helpful to enhance the exception message thrown by WebDriverWait when a condition times out. Specifically, include:

  • The expected condition (via .toString())
  • The total timeout duration
  • The locator (where applicable)

This added context can help quickly identify the exact point of failure without having to dig into logs or source code.

Example

Current:

Timed out waiting for condition.

Proposed: Timed out after 10 seconds waiting for condition: visibility of element located by By.id("login")

Why This Matters

  • This is a small, backward-compatible improvement with high practical value
  • Helps quickly debug flaky or failing tests.

I’d be happy to raise a PR for this enhancement, if this sounds useful.

Have you considered any alternatives or workarounds?

No response

ceekay10 avatar Jul 07 '25 06:07 ceekay10

@sarathckrishnan, thank you for creating this issue. We will troubleshoot it as soon as we can.

Selenium Triage Team: remember to follow the Triage Guide

selenium-ci avatar Jul 07 '25 06:07 selenium-ci

I’d be happy to raise a PR for this enhancement, if this sounds useful.

Which language bindings are you referring to?

Can you also verify you are human? ... this request sounds totally AI-generated.

cgoldberg avatar Jul 07 '25 13:07 cgoldberg

@cgoldberg šŸ‘‹ - I wanted to do it for Java binding. Sorry for using AI to paraphrase my thoughts. I'll edit my request.

ceekay10 avatar Jul 08 '25 10:07 ceekay10

@skrish99hsirks You are welcome to send in a PR with the suggested changes. We are happy to receive contributions.

pujagani avatar Jul 25 '25 08:07 pujagani

Hi, @ceekay10.

This is related to code in the Support packages. The support packages contain example code that many users find helpful, but they do not necessarily represent the best practices for using Selenium, and the Selenium team is not prioritizing work on them right now. This doesn't mean that we won't ever work on them, but it is not on our long term roadmap.

We actively encourage people to create their own wrapper and helper code that makes sense for them. If you have any questions, please contact us

selenium-ci avatar Nov 26 '25 00:11 selenium-ci