Execute JavaScript
Runs JavaScript in the browser's active tab, on the page or on an element, with input arguments, and returns its result as text, a number, a boolean or JSON.
Behaviour
Risk: High · Idempotent: No · Safe to retry: No · Recovery: Not replayed after a crash
Package UI Automation activities VeloPhex.UIAutomation.Activities 0.7.1-rc.12 · Supported (Core profile) · type id velophex.ui.executeJavaScript
Windows · Needs an interactive desktop session
Properties#
Input#
Target#
Target · String · Optional · Default: Not specified in package metadata
An element of the page a function script receives as its first parameter. Empty runs the script on the page.
Script#
Script · String · Required · Default: Not specified in package metadata
JavaScript code; its value is the result. A function, e.g. (element, args) => element.value + args.suffix, is called with the element (or null) and the parsed Input arguments, and its awaited return value is the result.
Input arguments#
InputArguments · String · Optional · Default: Not specified in package metadata
JSON passed to a function script as its second parameter, e.g. {"suffix": "-1"}.
Input element#
InputElement · String · Optional · Default: Not specified in package metadata
An element an earlier activity found (its Output element), passed instead of Target.
Output type#
OutputType · String · Optional · Default: String
What Value holds: String (the result as text; anything else as JSON), Number, Boolean or Json (a JSON element).
Allowed values: String, Number, Boolean, Json.
Session#
Session · String · Optional · Default: Not specified in package metadata
The session id from a Use Application/Browser scope. Empty uses the enclosing scope's session, or outside a scope the most recent matching session.
Timeout (seconds)#
TimeoutSeconds · Int32 · Optional · Default: Not specified in package metadata
How long to keep looking for the element or window. Empty or not positive means the same as the enclosing Use Application/Browser scope, or outside a scope the project default (30 seconds).
Highlight before action#
HighlightBeforeAction · Boolean · Optional · Default: Not specified in package metadata
Draw the highlight around the element before acting on it.
Output#
Result#
Result · String · Output
The result as text: a string as it is, anything else as JSON; empty for null or undefined.
Value#
Value · Object · Output
The result as Output type says: a string, a number (Double), a boolean or a JSON element.
Rules#
- Must be inside Use Application/Browser.
- Set only one of: Target, Input element.
Retry and risk#
This activity is not marked safe to retry: if it fails partway, check whether its work already happened before running it again. If a run is interrupted and the outcome of a step is unknown, the step is never retried automatically (what to do). How activities declare this: characteristics, retries and risk.
Every activity also has the engine's common properties: Timeout and Continue On Error.
Related activities#
Generated from VeloPhex.UIAutomation.Activities 0.7.1-rc.12. Category: UI Automation › Browser Data. Keywords: ui, automation, element, javascript, script, js, inject, evaluate, run.
Properties
Input
Output
Rules
Retry and risk
Related activities