- 入门指南
- 设置和配置
- 自动化项目
- 依赖项
- 工作流类型
- 控制流程
- 文件比较
- 自动化最佳实践
- 源代码控件集成
- 调试
- 日志记录
- 诊断工具
- 工作流分析器
- 变量
- 参数
- 导入的命名空间
- 编码自动化
- 基于触发器的 Attended 自动化
- 对象存储库
- ScreenScrapeJavaSupport 工具
- 扩展程序
- Studio 测试
- 故障排除
Studio 用户指南
本教程分步指导您创建编码测试用例,该用例在网页表单中输入信息,并使用 Test Manager 进行验证。为了自动化并访问网页表单,该示例使用了对象存储库元素和 UIAutomation。您可以在此处访问示例表单。
先决条件
- UiAutomation.Activities 23.10
- Testing.Activities 23.10
- UiPath Chrome 扩展程序
- 创建编码测试用例。 从“文件”组中选择“新建”,然后选择“编码测试用例”。
测试用例的代码分为三部分 (Arrange-Act-Assert),与 Given-When-Then 模板类似。
- 排列 – 设置测试数据。
- 执行 – 执行测试用例步骤。
- 断言 – 验证测试用例结果。
-
从测试应用程序中检索用户界面元素,以便您可以在编码测试用例中使用它们。 在此示例中,从网页表单中检索用户界面元素。 转到“对象存储库”选项卡,然后创建一个名为 TestForm 的应用程序。
-
在 TestForm 应用程序中,创建一个名为 TestFormScreen 的屏幕,并指示网页表单打开的 Chrome 选项卡。
-
在“TestFormScreen”中,为每个表单字段创建一个元素,并在表单内部创建按钮。 用户界面元素按字母顺序按升序排列。
-
var screen = uiAutomation.Open(ObjectRepository.Descriptors.TestForm.TestFormScreen); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Name, "John Doe"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Email, "john.doe@uipath.com"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Password, "1234"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.ConfirmPassword, "1234");var screen = uiAutomation.Open(ObjectRepository.Descriptors.TestForm.TestFormScreen); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Name, "John Doe"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Email, "john.doe@uipath.com"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.Password, "1234"); screen.TypeInto(ObjectRepository.Descriptors.TestForm.TestFormScreen.ConfirmPassword, "1234");提示:在 Studio IDE 中使用 IntelliSense。 按下
Ctrl+Space键即可使用 IntelliSense 执行以下操作:- 自动完成代码
- 读取编码自动化 API 文档 – 读取 API 的参数。 在编码自动化生态系统中,API 参数相当于活动属性。
7. In the Act section type the action of submitting the form. For this example, use the following code sample:
screen.Click("Submit");
screen.Click("Submit");
8. In the Assert section use the Testing service, along with the VerifyExpression coded automation API, to verify if the text inside Verification is the username input from step 6. For this example, use the following code sample:
testing.VerifyExpression(screen.GetText("Verification") == "John Doe");
testing.VerifyExpression(screen.GetText("Verification") == "John Doe");
示例项目
要按照步骤操作并自行尝试教程,请下载以下示例项目:第一个编码测试用例。