ElementQuery.waitForFirst has been deprecated, presumably to guide users to use single() instead, which is a more specific query. The JavaDoc for the deprecation mentions to write a custom wait loop and use single(). However, looking at the implementation for waitForFirst users would have to replace this one liner with quite a bit of (Selenium) code and exception handling:
T result = new WebDriverWait(getDriver(),
Duration.ofSeconds(timeOutInSeconds)).until(driver -> {
try {
return first();
} catch (NoSuchElementException e) {
return null;
}
});
if (result == null) {
throw new NoSuchElementException(getNoSuchElementMessage(null));
} else {
return result;
}
There should be an alternative for ElementQuery.waitForFirst that does not require implementing the above manually, or at least the deprecation notice should provide a proper solution for how to implement this yourself.
ElementQuery.waitForFirsthas been deprecated, presumably to guide users to usesingle()instead, which is a more specific query. The JavaDoc for the deprecation mentions to write a custom wait loop and usesingle(). However, looking at the implementation forwaitForFirstusers would have to replace this one liner with quite a bit of (Selenium) code and exception handling:There should be an alternative for
ElementQuery.waitForFirstthat does not require implementing the above manually, or at least the deprecation notice should provide a proper solution for how to implement this yourself.