com.atlassian.pageobjects.elements
Interface PageElementJavascript


public interface PageElementJavascript

Encapsulates Javascript functionality of the PageElement.

PageElement.isPresent() of the corresponding page element must return true before any of the methods of this interface are invoked, otherwise NoSuchElementException will be raised.

Since:
2.1

Method Summary
<T> T
execute(Class<T> resultType, String script, Object... arguments)
          

Provides the same functionality as execute(String, Object...), but lets the client specify the expected result type.

 Object execute(String script, Object... arguments)
          

Executes custom script on this element.

<T> T
executeAsync(Class<T> resultType, String script, Object... arguments)
          

Provides the same functionality as executeAsync(Class, String, Object...), but lets the client specify the expected result type.

 Object executeAsync(String script, Object... arguments)
          

Executes custom script on this element asynchronously.

<T> TimedQuery<T>
executeTimed(Class<T> resultType, String script, Object... arguments)
          

Executes custom script on this element in a periodic manner, allowing the client to wait for a particular expected result to occur (via the returned TimedQuery).

 PageElementFormJavascript form()
          Access to form events for the associated page element.
 PageElementMouseJavascript mouse()
          Access to mouse events for the associated page element.
 

Method Detail

mouse

PageElementMouseJavascript mouse()
Access to mouse events for the associated page element.

Returns:
mouse events for the element

form

PageElementFormJavascript form()
Access to form events for the associated page element.

Returns:
form events for the element

execute

Object execute(String script,
               Object... arguments)

Executes custom script on this element.

The corresponding HTML element will be available in the executing script under arguments[0] entry. The provided arguments will be available under subsequents entries in the 'arguments' magic variable, as stated in JavascriptExecutor.executeScript(String, Object...).

The arguments and return type are as in JavascriptExecutor.executeScript(String, Object...) with addition of PageElements as valid argument type.

When a DOM element is returned from the script, a corresponding PageElement instance will be returned from this method

Parameters:
script - javascript to execute
arguments - custom arguments to the script. a number, a boolean, a String, a PageElement, a WebElement or a List of any combination of the above
Returns:
One of Boolean, Long, String, List or PageElement, or null.
Throws:
NullPointerException - if script is null
See Also:
JavascriptExecutor.executeScript(String, Object...)

execute

<T> T execute(Class<T> resultType,
              String script,
              Object... arguments)

Provides the same functionality as execute(String, Object...), but lets the client specify the expected result type. The expected result type must not be null and must match the actual result from the executed script.

Parameters:
resultType - expected type of the result. One of Boolean, Long, String, List or PageElement . Must not be null
script - javascript to execute
arguments - custom arguments to the script. a number, a boolean, a String, a PageElement, a WebElement or a List of any combination of the above
Returns:
result of the script converted to the resultType
Throws:
NullPointerException - if script or resultType is null
IllegalArgumentException - if resultType is not one of the expected types
ClassCastException - if the actual result type does not match resultType
See Also:
execute(String, Object...)

executeTimed

<T> TimedQuery<T> executeTimed(Class<T> resultType,
                               String script,
                               Object... arguments)

Executes custom script on this element in a periodic manner, allowing the client to wait for a particular expected result to occur (via the returned TimedQuery).

All rules (in particular with regards to the result type) of execute(String, Object...) apply to this method.

The caller must provide the expected return type as resultType. It must be one of the valid result types or an exception will be raised.

Parameters:
resultType - expected type of the result. One of Boolean, Long, String or List. Must not be null
script - javascript to execute
arguments - custom arguments to the script. a number, a boolean, a String, a PageElement, a WebElement or a List of any combination of the above
Returns:
TimedQuery to query for the expected result
Throws:
NullPointerException - if script or resultType is null
IllegalArgumentException - if resultType is not one of the expected types
ClassCastException - if the actual result type does not match resultType
See Also:
JavascriptExecutor.executeScript(String, Object...), execute(String, Object...)

executeAsync

Object executeAsync(String script,
                    Object... arguments)

Executes custom script on this element asynchronously.

All rules and conditions of execute(String, Object...) apply, except the last argument in the 'arguments' magic variable in the script is a callback that has to be invoked and given result of the script so that this method returns. See JavascriptExecutor.executeAsyncScript(String, Object...) for details.

Consider using executeTimed(Class, String, Object...) instead.

Parameters:
script - javascript to execute
arguments - custom arguments to the script. a number, a boolean, a String, a PageElement, a WebElement or a List of any combination of the above
Returns:
One of Boolean, Long, String, List or PageElement. Or null.
Throws:
NullPointerException - if script is null
See Also:
(String, Object...), execute(String, Object...)

executeAsync

<T> T executeAsync(Class<T> resultType,
                   String script,
                   Object... arguments)

Provides the same functionality as executeAsync(Class, String, Object...), but lets the client specify the expected result type. The expected result type must not be null and must match the actual result from the executed script.

Consider using executeTimed(Class, String, Object...) instead.

Parameters:
resultType - expected type of the result. One of Boolean, Long, String, List or PageElement . Must not be null
script - javascript to execute
arguments - custom arguments to the script. a number, a boolean, a String, a PageElement, a WebElement or a List of any combination of the above
Returns:
result of the script converted to the resultType
Throws:
NullPointerException - if script or resultType is null
IllegalArgumentException - if resultType is not one of the expected types
ClassCastException - if the actual result type does not match resultType
See Also:
(String, Object...)


Copyright © 2014 Atlassian. All rights reserved.