- Robot JavaScript SDK
配置步骤
Robot JavaScript SDK 的先决条件和配置步骤:JavaScript 插件安装和应用程序访问设置。
本页介绍在自定义网页应用程序中使用机器人 JavaScript SDK 的先决条件和配置,包括设置浏览器和机器人同意访问权限、安装 SDK 以及配置 JavaScript 插件。
先决条件
自动化项目必须满足以下先决条件才能使用 Robot JavaScript SDK:
- UiPath Robot 2026.10 installed
- 在机器人计算机上安装 UiPath JavaScript 插件
允许访问
运行 UiPath 机器人 JavaScript 插件时,您必须获得对自定义应用程序或网页的访问权限,以连接到机器人。访问权限由两步对话框处理 — 必须确认两个步骤才能运行 RobotJS。这两个对话框都支持自动化,如以下各节所述。
浏览器访问对话框
此步骤是指浏览器请求打开 UiPath Assistant 的权限。
“自动接受浏览器访问”对话框
The uipath-web protocol is the UiPath Robot web protocol handler. Browsers ask for permission before they open it. You can automate this dialog through your browser's enterprise policies.
Based on the browser used, different settings need to be configured. For the exact policy and value format, see the enterprise policy documentation of your browser.
机器人同意对话框
机器人同意对话框用于允许机器人 JavaScript SDK 和机器人执行程序之间建立连接。
自动接受机器人同意对话框
UIPATH_ROBOTJS_ALLOWLIST 系统环境变量会自动接受机器人同意对话框。
The value is a list of origins separated by semicolons. Each origin includes the scheme, for example https://myapp.contoso.com. Add the port only if it is not the default (80 or 443).
示例:
UIPATH_ROBOTJS_ALLOWLIST=https://cloud.uipath.com;https://mydomain.com
UIPATH_ROBOTJS_ALLOWLIST=https://cloud.uipath.com;https://mydomain.com
The Robot already accepts the UiPath cloud origins by default, so you only add your own origins. For the default list, see the AllowUrlList key in Configuration files.
Robot JavaScript SDK
This SDK provides all the necessary methods and properties you can include in your custom application or web page. It is available as an npm package with TypeScript bindings. To include it in your project:
-
在项目目录的根目录运行以下命令:
npm install --save @uipath/robotnpm install --save @uipath/robot
要改为加载带有<script>标签的 SDK,请使用包中的dist/js/UiPathRobot.js 。
版本 1.3.3,最后一个发布到 download.uipath.com,在https://download.uipath.com/js/1.3.3/UiPathRobot.js仍可用。较新的版本仅在 npm 上发布。
插件设定
要配置加载项设置:
- Open the
UiPath.configfile:%ProgramFiles%\UiPathPlatform\Robot\<version>\UiPath.configfor a per-machine installation, or%LocalAppData%\Programs\UiPathPlatform\Robot\<version>\UiPath.configfor a per-user installation. For details, see Configuration files. - 将
ListenerPort和TokenExpiryInDays参数添加到<robotJsSettings>部分。默认情况下,该部分不包含任何键:
<robotJsSettings>
<add key="ListenerPort" value="2323" />
<add key="TokenExpiryInDays" value="30" />
</robotJsSettings>
<robotJsSettings>
<add key="ListenerPort" value="2323" />
<add key="TokenExpiryInDays" value="30" />
</robotJsSettings>
| 属性 | 描述 |
|---|---|
ListenerPort | The UiPath.RobotJS.ServiceHost.exe starts a HttpListener on the configured port and contains the information about other local listeners from the active user session on that system. The port value must match the one configured in the SDK Settings. The default value is 2323. |
TokenExpiryInDays | Any request coming from a new domain needs to have consent from the user to allow access of UiPath Robots from a web application. These consents are valid for the said number of days mentioned in this setting. The default value is 30. |
After you edit the file, restart the UiPath RobotJS Service service for the changes to take effect. For the steps, see Restarting robot components.