I don't understand what's happening with the newer version of Selenium's WebDriverWait but as far as I can see, it's not behaving the way I'd expect it to.
I have tried all the versions from 4.0.0-beta-1 - 4.0.0-beta-4 and I have just updated to 4.0.0-beta-4 as my preferred version.
I use these methods in my own functions:
Each of them have their respective constructors that they call:
A couple of things that I found:
Previously, you could write it like this:
Now, it looks like this (as shown above):
The only difference being how you define the wait.
With using Duration, you can specify the "type":
In my above code example, I define the WebDriverWait using the Duration.ofSeconds(1L), meaning it should wait for just 1 second, however, it waits for 10 seconds instead.
In fact, it waits for 10 seconds whether it's set to Duration.ofMillis or Duration.ofNanos too.
So, either I really don't understand the implementation correctly, or there's something I am missing, or there's an issue with the actual WebDriverWait class.
It's also worth mentioning, it doesn't wait 10 seconds whether the WebElement exists or not, it only waits the full duration if the WebElement does NOT exist.
Hoping someone can assist with this.