Call a JavaScript function action
- Updated: 2022/12/14
Call a JavaScript function action
The Call a JavaScript function action in the Browser package enables you to call an exisiting JavaScript function directly in a webpage or in an iFrame within a webpage.
Configure the settings
Note: This action supports Google Chrome and Chromium-based Microsoft Edge browsers.
- Select the browser tab from the list of active supported browser tabs or insert
a window variable.
You can use a regular expression (regex) to identify a window title. Select the regular expression condition as either String or a Pattern and then enter the value. By default, the Window title field is case-sensitive.
To identify a browser title, you can enable the Case sensitive option to match the letter case, or disable the option to identify a window title where the letter case does not match.Note: Ensure that the minimum Bot Agent version installed on your system is the version that was released with Automation 360 v.26. If you have a Bot Agent version released with Automation 360 v.25 or earlier, then by default, the window title will be identified only with matching letter case (case-sensitive).For example, to match all window title names beginning with a word followed by- Notepad
, you can enter the String value as * -Notepad, or use Pattern value as ((\w)\s)*document-Notepad for only those window titles that match this pattern.Note:- When you use a regular expression of type String with -title as the input value for a window title in any action, the bot might encounter a run time error. To prevent the run time error, ensure that when you add the string input as *-title, the application with the specific title is open. The asterisk (*) is just a character, not a wild card character.
- When you use a regular expression of type Pattern with
-title as the input value for a window title in any
action, the bot might encounter a run time
error because the input value *-title is
incorrect.
Ensure that you use valid regex patterns.
-
Optional: Use the Capture object option to capture
the iFrames.Note: You can use the Capture object feature to call and run an existing JavaScript function inside an iFrame.
- In the Function name field, specify the name of the existing JavaScript function that you want to call.
-
Optional: In the Arguments section, click
Add argument to add arguments that must be passed to
call the JavaScript function.
- In the Argument details dialog box, select the Argument type required for the specific argument.
- In the value field, enter the corresponding value
or variable of the selected type that you want to pass.Note: All string values in arguments are passed as is without any character being converted or escaped.
-
Optional: In the Time out after field, enter the
number of seconds the bot must wait for the browser action to
complete. Note: Enter a timeout value of at least 9 seconds.
- In the Return Type field, select the type of value
returned by the JavaScript function.Note: If the function does not return anything, in the Return Type field, select None.
- For any Return type except None, in the Save the outcome to a variable field, select a variable for selected Return type to hold the JavaScript function output.
Create variable
To create a variable for selected Return type, perform the
following steps:
- Click the Create variable symbol next to the Save the outcome to
a variable field.
A Create variable dialog opens with default variable name for the type of variable selected.
- Optional: Specify the variable information in the Description field.
- Optional: Specify a value in the Default value field.
- Click Create & select to select the newly created variable.
Supported JavaScript types in Argument and Return type fields
The following JavaScript types are supported:
- String, Number, and Boolean JavaScript types which correspond to the same variable types in bot variables.
- Array JavaScript type which corresponds to the List variable type in bot variables.
- Object JavaScript type which corresponds to the Dictionary variable type in bot variables.