Class JavascriptExecutorFacade


  • public class JavascriptExecutorFacade
    extends Object
    Simple encapsulation of Javascript execution.
    • Constructor Detail

      • JavascriptExecutorFacade

        public JavascriptExecutorFacade​(org.openqa.selenium.WebDriver driver)
      • JavascriptExecutorFacade

        public JavascriptExecutorFacade()
    • Method Detail

      • getGson

        protected com.google.gson.Gson getGson()
      • registerTypeAdapter

        public void registerTypeAdapter​(Type type,
                                        Object typeAdapter)
        Register a GSon type adaptor to use during the JSON deserialization
        Parameters:
        type -
        typeAdapter -
      • executeScript

        public Object executeScript​(String script)
        Execute some Javascript in the underlying WebDriver driver.
        Parameters:
        script -
      • executeAsyncScript

        public Object executeAsyncScript​(String script)
      • executeAsyncScript

        public Object executeAsyncScript​(String script,
                                         Object... params)
      • deserializeScriptResultAs

        public <T> T deserializeScriptResultAs​(Class<T> classOfT,
                                               String script,
                                               Object... params)
                                        throws IllegalAccessException
        Executes the JavaScript code and deserializes the resulting object as a classOfT.
        Parameters:
        classOfT - Java Class
        script - that returns JavaScript Object
        params - a map of parameters to inject into the deserialized object
        Returns:
        deserialized as classOfT object
        Throws:
        IllegalAccessException
      • deserializeScriptResultAsListOf

        public <T> List<T> deserializeScriptResultAsListOf​(String script,
                                                           Object... params)
        Executes the JavaScript code and deserializes the resulting object as a List.
        Parameters:
        script - that returns JavaScript Object
        Returns:
        deserialized as List of classOfT