Call a JavaScript function action
- Updated: 2025/07/04
Call a JavaScript function action
The Call a JavaScript function action in the Browser package enables you to call an existing JavaScript function directly in a webpage or in an iFrame within a webpage. This action also allows you to call a JavaScript function in desktop Chromium Embedded Framework (CEF) applications.
Configure the settings
Note:
- For macOS platform, this action supports Google Chrome and Safari browsers.
- For Windows platform, this action supports Google Chrome and Chromium-based Microsoft Edge browsers.
- This action supports CEF-based desktop applications.
- Select the browser tab from the list of active supported browser tabs or insert a
window variable. To call a JavaScript function in CEF applications, use the
Application tab. From the
Application tab, select the specific CEF application from
the list of applications. A CEF application integrates web browser functionality by
embedding Chromium into a desktop application.Important:
- To automate desktop applications that use CEF framework, you must develop and run your automations in elevated mode. See Automate applications running as an admin user.
- To automate CEF applications, ensure you use the Browser package version 3.13.1 and later.
Note:- Automating cross domain iFrame in CEF applications is not supported.
- CEF applications will not be listed under the Browser tab.
您可以使用正则表达式 (regex) 来标识窗口标题。 将每个正则表达式条件选择为字符串或模式,然后输入值。 默认情况下,窗口标题字段区分大小写。
要识别浏览器标题,您可以启用区分大小写选项以匹配字母大小写,或禁用该选项以识别字母大小写不匹配的窗口标题。Note: 确保您系统上安装的最低 Bot Agent 版本是随 Automation 360 v.26 发布的版本。 如果存在随 Automation 360 v.25 或更早版本发布的 Bot Agent 版本,则默认情况下,将仅通过匹配字母大小写(区分大小写)识别窗口标题。例如,要匹配所有以单词开头、后跟- Notepad
的窗口标题名称,您可以输入字符串值 * -Notepad,或者仅为与此模式匹配的窗口标题使用模式值 ((\w)\s)*document-Notepad。Note:- 当您使用类型为字符串的正则表达式,并将 -title 作为任何 action 的窗口标题的输入值时,bot 可能会遇到运行时错误。 为了防止运行时错误,请确保在将字符串输入添加为 *-title 时,具有特定标题的应用程序已打开。 星号 (*) 只是一个字符,而不是通配符。
- 当您使用类型为 Pattern 的正则表达式,并将 -title 作为任何 action 的窗口标题的输入值时,bot 可能会遇到运行时错误,因为输入值 *-title 是不正确的。
请确保使用有效的正则表达式模式。
-
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.