Skip to content

WebDriverWait should have Duration-based constructors #7187

@kluever

Description

@kluever

🚀 Feature Proposal

WebDriverWait currently has the following public constructors:

  • WebDriverWait(WebDriver driver, long timeOutInSeconds)
  • WebDriverWait(WebDriver driver, long timeOutInSeconds, long sleepInMillis)
  • WebDriverWait(WebDriver driver, java.time.Clock clock, Sleeper sleeper, long timeOutInSeconds, long sleepTimeOut)

The existing constructors should be deprecated (and removed?) in favor of java.time.Duration-based ones.

Motivation

The long parameters are worrisome. We've seen hundreds of "unit mismatch" bugs inside of Google when using a numeric primitive instead of a Duration.

Additionally, the existing constructors don't follow best practices w.r.t. parameter overloading (the ctors are effectively: init(A, B), init(A, B, C), init(A, D, E, B, C)).

Example

Assuming all of these ctor combinations are necessary, I'd suggest going with:

  • WebDriverWait(WebDriver driver, Duration timeOut)
  • WebDriverWait(WebDriver driver, Duration timeOut, Duration sleep)
  • WebDriverWait(WebDriver driver, Duration timeOut, Duration sleep, Clock clock, Sleeper sleeper)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-javaJava Bindings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions