public static ExpectedCondition < Boolean > or ( final ExpectedCondition < ? > ... conditions ) { return new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { RuntimeException lastException = null ; for ( ExpectedCondition < ? > condition : conditions ) { try { Object result = condition . apply ( driver ) ; if ( result != null ) { if ( result instanceof Boolean ) { if ( Boolean . TRUE . equals ( result ) ) { return true ; } } else { return true ; } } } catch ( RuntimeException e ) { lastException = e ; } } if ( lastException != null ) { throw lastException ; } return false ; } @ Override public String toString ( ) { StringBuilder message = new StringBuilder ( "at least one condition to be valid: " ) ; Joiner . on ( " || " ) . appendTo ( message , conditions ) ; return message . toString ( ) ; } } ; }
An expectation with the logical or condition of the given list of conditions .