预期异常
动词:expectedException
可从以下位置获取: <Enterprise>
通过 IBM RPA Studio的测试资源管理器验证脚本中的异常方案,核准或不核准这些方案。
语法
expectedException --exception(String) --message(String)
输入
| 脚本 | 设计器 | 必需的 | AcceptedTypes | Description |
|---|---|---|---|---|
| --exception | 异常 | 必需的 | 文本 | 表示脚本执行期间预期的异常的文本。 一些预期的异常类型包括: 有关更多类型,请访问异常 Class.NET。 |
| -- 消息 | 消息 | 必需的 | 文本 | 未发生预期的异常时将显示的已注册文本。 |
示例
Click 命令尝试单击 "ID" 值等于 "Name" 的记事本元素; 由于找不到此元素,因此在 IBM RPA Studio上发生名为 "RuntimeException" 的映射错误。 该错误是预期的,因此将在测试资源管理器中显示消息“已核准”。
defVar --name window --type Window
expectedException --exception RuntimeException --message "not find"
launchWindow --executablepath "notepad.exe" window=value
focusWindow --window ${window}
click --selector "Id" --controlsimilarity 100 --id Name --timeout 00:00:01
// After following the instructions, the test is expected to produce the following result:
// expectedException.wal
// [APPROVED] ExpectedException
1. 异常方案的验证通过 IBM RPA Studio的 "测试资源管理器" 进行可视化。
2. 要使用 IBM RPA Studio "测试资源管理器" ,必须首先保存样本脚本,然后转至路径上的顶部菜单:*视图 > 测试资源管理器 > 折叠所有项 > 选择将脚本保存到的文件夹 > 将列出文件夹和子文件夹中的所有脚本 > 右键单击已保存的示例脚本 > 运行所选测试*。
备注
如果异常位于 IBM Robotic Process Automation 测试器外部,那么预期异常命令无法高效地捕获到该异常。 不会在流程自动化期间使用此命令。