public static JavascriptExecutor getJavascriptExecutor ( SearchContext searchContext ) { JavascriptExecutor executor = null ; if ( searchContext instanceof JavascriptExecutor ) { executor = ( JavascriptExecutor ) searchContext ; } else { if ( searchContext instanceof WrapsDriver ) { WrapsDriver wraps = ( WrapsDriver ) searchContext ; WebDriver wrapped = wraps . getWrappedDriver ( ) ; if ( wrapped instanceof JavascriptExecutor ) { executor = ( JavascriptExecutor ) wrapped ; } } } if ( executor == null ) { throw new IllegalArgumentException ( "Unable to get: " + JavascriptExecutor . class . getName ( ) + " from: " + searchContext . getClass ( ) . getName ( ) ) ; } return executor ; }
Obtains executor based on Selenium context .