public static ExpectedCondition < Boolean > javaScriptThrowsNoExceptions ( final String javaScript ) { return new ExpectedCondition < Boolean > ( ) { @ Override public Boolean apply ( WebDriver driver ) { try { ( ( JavascriptExecutor ) driver ) . executeScript ( javaScript ) ; return true ; } catch ( WebDriverException e ) { return false ; } } @ Override public String toString ( ) { return String . format ( "js %s to be executable" , javaScript ) ; } } ; }
An expectation to check if js executable .