private List < WebElement > getListWebElements ( Callable < List < WebElement > > callable ) { int retries = 0 ; long expireTime = Instant . now ( ) . toEpochMilli ( ) + SECONDS . toMillis ( INTERACT_WAIT_S ) ; while ( Instant . now ( ) . toEpochMilli ( ) < expireTime && retries < LOCATE_RETRIES ) { try { List < WebElement > elements = callable . call ( ) ; if ( elements . size ( ) == 0 ) continue ; return elements ; } catch ( WebDriverException e ) { retries ++ ; } catch ( Exception e ) { Throwables . propagate ( e ) ; } } // no elements found so return an empty list return new ArrayList <> ( ) ; }
If nothing found by the timeout return an empty list