public Object eval ( String javascriptFunction ) { if ( ! element . is ( ) . present ( ) ) { return null ; } try { WebElement webElement = element . getWebElement ( ) ; JavascriptExecutor js = ( JavascriptExecutor ) driver ; return js . executeScript ( javascriptFunction , webElement ) ; } catch ( NoSuchMethodError | Exception e ) { log . warn ( e ) ; return null ; } }
Executes a provided script on the element and returns the output of that script . If the element doesn t exist or there is an error executing this script a null value will be returned .