Description
This activity allows you to execute separately written JavaScript code in relation to the currently opened page in the browser. In some cases, using JavaScript code makes it much easier to develop a workflow. You can debug the code separately in your preferred IDE and compare versions.
Note: the code itself should be a single function with no more than one argument of any type and, if necessary, return some value.
Note: It is preferable to use UTF-8
encoding in the .js file. Other encodings, such as UTF-16 LE
, may cause errors.
Parameters
JavaScript file
- Set a value option allows you to set a path to the .js file manually. By clicking PICK you can find the desired file using file explorer.
- Calculate a value option lets you use a special formula or method to set a path to the .js file.
- Save the previous step result option takes the path to the .js file from the result of the previous step in the workflow.
Input parameter
This parameter allows you to pass a single argument as a string or integer. Use an array or a JSON object to pass multiple arguments.
- Set a value option allows you to set the input parameter manually.
- Calculate a value option lets you use a special formula or method to set the input parameter.
- Save the previous step result option takes the input parameter from the result of the last step in the workflow.
This activity supports having async
functions in the JavaScript code:
async function () {
// here goes your code
}
On tab
This parameter allows you to specify the name of the tab that you want the bot to interact with. The name of the tab is assigned in the "Open URL" activity.
-
Set a value allows you to manually specify the name of the tab.
-
Calculate a value allows you to use a special formula or a particular method to determine the name of the tab.
-
Save the previous step result takes the result of the previous workflow action as the name of the tab.
Use tab name in order
This checkbox allows you to specify a sequential number of a tab in the browser. It is worth using if a new tab opens not manually, but automatically after clicking on some element.
In iframe
This parameter allows you to select a specific iframe on a page where the JavaScript code is to be executed.
Timeout, sec
This parameter allows you to set the timeout for the activity's execution.
Wait before, sec
This option allows you to set the delay before the execution of the activity. The delay is set in seconds.
Wait after, sec
This option allows you to set the delay after the execution of the activity. The value is set in seconds.
Comment
This parameter allows you to create an annotation of the activity. The input text will be displayed above the activity name.
How to use it?
Using the JavaScript code activity on a particular webpage allows you to extend your automation capabilities, and make the best out of the power of JavaScript and interaction with DOM elements. This will make it possible to handle some tricky scenarios pretty easily.
Here you can find an example of the workflow with the JavaScript code implemented: