Class FluentJavascript


  • public class FluentJavascript
    extends java.lang.Object
    Execute a script and map it's result.
    See Also:
    JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
    • Constructor Summary

      Constructors 
      Constructor Description
      FluentJavascript​(org.openqa.selenium.JavascriptExecutor executor, boolean async, java.lang.String script, java.lang.Object... args)
      Creates a new fluent javascript.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.Boolean getBooleanResult()
      Retrieve the result as a Boolean.
      java.lang.Double getDoubleResult()
      Retrieve the result as a Double.
      java.util.List<?> getListResult()
      Retrieve the result as a List.
      <T> java.util.List<T> getListResult​(java.lang.Class<T> listType)
      Retrieve the result as a typed List
      java.lang.Long getLongResult()
      Retrieve the result as a Long.
      java.lang.Object getResult()
      Retrieve the result of the script execution.
      java.lang.String getStringResult()
      Retrieve the result as a String.
      boolean isBooleanResult()
      Check if the result is a Boolean.
      boolean isDoubleResult()
      Check if the result is a Double.
      boolean isListResult()
      Check if the result is a List.
      boolean isLongResult()
      Check if the result is a Long.
      boolean isStringResult()
      Check if the result is a String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FluentJavascript

        public FluentJavascript​(org.openqa.selenium.JavascriptExecutor executor,
                                boolean async,
                                java.lang.String script,
                                java.lang.Object... args)
        Creates a new fluent javascript.
        Parameters:
        executor - underlying javascript executor
        async - if true, scripts will be executed asynchronously, else it will be executed synchronously
        script - script source to execute
        args - script arguments
    • Method Detail

      • isStringResult

        public boolean isStringResult()
        Check if the result is a String.
        Returns:
        true if the result of javascript execution can be retrieved as a String
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • isBooleanResult

        public boolean isBooleanResult()
        Check if the result is a Boolean.
        Returns:
        true if the result of javascript execution can be retrieved as a Boolean
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • isDoubleResult

        public boolean isDoubleResult()
        Check if the result is a Double.
        Returns:
        true if the result of javascript execution can be retrieved as a Double
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • isLongResult

        public boolean isLongResult()
        Check if the result is a Long.
        Returns:
        true if the result of javascript execution can be retrieved as a Long
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • isListResult

        public boolean isListResult()
        Check if the result is a List.
        Returns:
        true if the result of javascript execution can be retrieved as a List
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getResult

        public java.lang.Object getResult()
        Retrieve the result of the script execution.
        Returns:
        the result.
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getDoubleResult

        public java.lang.Double getDoubleResult()
        Retrieve the result as a Double.
        Returns:
        the result of script execution cast as a Double
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getBooleanResult

        public java.lang.Boolean getBooleanResult()
        Retrieve the result as a Boolean.
        Returns:
        the result of script execution cast as a Boolean
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getLongResult

        public java.lang.Long getLongResult()
        Retrieve the result as a Long.
        Returns:
        the result of script execution cast as a Long
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getStringResult

        public java.lang.String getStringResult()
        Retrieve the result as a String.
        Returns:
        the result of script execution cast as a String
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getListResult

        public java.util.List<?> getListResult()
        Retrieve the result as a List.
        Returns:
        result of javascript script cast as a List
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)
      • getListResult

        public <T> java.util.List<T> getListResult​(java.lang.Class<T> listType)
        Retrieve the result as a typed List
        Type Parameters:
        T - type of list elements
        Parameters:
        listType - class of list elements
        Returns:
        the result of javascript execution cast as a a typed List
        See Also:
        JavascriptExecutor.executeScript(java.lang.String, java.lang.Object...)