79796939

Date: 2025-10-22 15:14:49
Score: 1.5
Natty:
Report link

I actually ended up with this:

val webElement = fluentWait.until(ExpectedConditions.presenceOfElementLocated(By.id(field)).andThen(_.click))

FluentWait requires a Truthy return type and the Unit returned by click is considered Truthy.

If click() throws a StaleElementReferenceException then this is ignored by the FluentWait and we poll again.

I tested this with debug logging and I definitely see the click retrying if the WebElement is stale.

Can anyone comment as to the correctness and safety of this implementation?

Reasons:
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
Posted by: Terry Dactyl