public class JavaScript
extends java.lang.Object
Browser.javaScript(String, Object...)
.
Executing a script returns either true if the result was non-false, or false if it was empty. Evaluating a script returns the return value of the script.
JavaScript can be executed or evaluated synchronously or asynchronously. The parameter is optional and can be used to execute the script on a specific object instead of the whole document.
evaluate(Browser, Object...)
evaluates the script synchronouslyevaluateAsync(Browser, Object...)
evaluates the script asynchronouslyConstructor and Description |
---|
JavaScript(java.lang.String script)
Constructs new BrowserJavaScript instance for running JavaScript.
|
JavaScript(java.lang.String script,
java.lang.Boolean isFile)
Constructs new BrowserJavaScript instance for running JavaScript.
|
Modifier and Type | Method and Description |
---|---|
JavaScriptResult |
evaluate(Browser browser,
java.lang.Object... args)
Evaluates JavaScript synchronously.
|
JavaScriptResult |
evaluateAsync(Browser browser,
java.lang.Object... args)
Evaluates JavaScript asynchronously.
|
public JavaScript(java.lang.String script)
script
- the JavaScript to execute or evaluatepublic JavaScript(java.lang.String script, java.lang.Boolean isFile)
script
- the JavaScript to execute or evaluateisFile
- if true, the script parameter is taken as JavaScript filename which contains the scriptpublic JavaScriptResult evaluate(Browser browser, java.lang.Object... args)
browser
- Browser
instance to work withargs
- optional list of objects which are passed to the script as arguments, accessable with arguments[0] etc.public JavaScriptResult evaluateAsync(Browser browser, java.lang.Object... args)
browser
- Browser
instance to work withargs
- optional list of objects which are passed to the script as arguments, accessable with arguments[0] etc.