- 概述
- 用户界面自动化
- 通过用户界面自动化实现自动化的应用程序和技术
- 项目兼容性
- UI-ANA-016 - 拉取打开浏览器 URL
- UI-ANA-017 - 出错时继续 True
- UI-ANA-018 - 列出 OCR/图像活动
- UI-DBP-006 - 容器使用情况
- UI-DBP-013 - Excel 自动化误用
- UI-DBP-030 - 选取器中的禁止变量使用情况
- UI-DBP-031 - 活动验证
- UI-PRR-001 - 模拟单击
- UI-PRR-002 - 模拟键入
- UI-PRR-003 - 打开应用程序误用
- UI-PRR-004 - 硬编码延迟
- UI-REL-001 - 选取器中的大 IDX
- UI-SEC-004 - 选取器电子邮件数据
- UI-SEC-010 - 应用程序/Url 限制
- UI-USG-011 - 不允许的属性
- UX-SEC-010 - 应用程序/Url 限制
- UX-DBP-029 - 使用不安全的密码
- UI-PST-001 - 项目设置中的审核日志级别
- UiPath 浏览器迁移工具
- 剪切区域
- 计算机视觉录制器
- 活动索引
- 激活
- 锚点基准
- 附加浏览器
- 附加窗口
- 阻止用户输入
- 标注
- 选中
- 单击
- 单击图像
- 单击图像触发器
- 单击 OCR 文本
- 单击文本
- 单击触发器
- 关闭应用程序
- 关闭选项卡
- 关闭窗口
- 上下文感知锚点
- 复制选定文本
- 元素属性更改触发器
- 存在元素
- 元素作用域
- 元素状态更改触发器
- 导出用户界面树
- 提取结构化数据
- 查找子元素
- 查找元素
- 查找图像
- 查找图像匹配项
- 查找 OCR 文本位置
- 查找相对元素
- 查找文本位置
- 获取活动窗口
- 获取上级
- 获取属性
- 获取事件信息
- 从剪贴板获取
- 获取全文
- 获取 OCR 文本
- 获取密码
- 获取位置
- 获取源元素
- 获取文本
- 获取可见文本
- 返回
- 前往
- 转至主页
- Google Cloud Vision OCR
- 隐藏窗口
- 高亮显示
- 热键触发器
- 悬停
- 悬停在图像上方
- 悬停在 OCR 文本上方
- 悬停文本
- 存在图像
- 在屏幕上指定
- 注入 .NET 代码
- 插入 Js 脚本
- 调用 ActiveX 方法
- 按键触发器
- 加载图像
- 最大化窗口
- Microsoft Azure 计算机视觉 OCR
- Microsoft OCR
- Microsoft Project Oxford Online OCR
- 最小化窗口
- 监控事件
- 鼠标触发器
- 移动窗口
- 导航至
- 存在 OCR 文本
- 在元素出现时
- 在元素消失时
- 在图像出现时
- 在图像消失时
- 打开应用程序
- 打开浏览器
- 刷新浏览器
- 重播用户事件
- 还原窗口
- 保存图像
- 选择项目
- 选择多个项目
- 发送热键
- 设置剪切区域
- 设置焦点
- 设置文本
- 设置为剪贴板
- 设置网页属性
- 显示窗口
- 启动进程
- 系统触发器
- 截取屏幕截图
- Tesseract OCR
- 存在文本
- 工具提示
- 键入
- 输入安全文本
- 使用前台
- 等待属性
- 等待元素消失
- 等待图像消失
- Computer Vision Local Server
- 移动自动化
- 终端

用户界面自动化活动
本快速入门指南可帮助您使用移动自动化 API 创建第一个编码自动化。本教程使用 UiPath™ Android 基本应用程序和 Sauce Labs 的 GooglePixel 模拟器进行自动化测试。
要在编码自动化中使用所需的移动设备和应用程序,我们必须首先在 MDM(移动设备管理器)中创建它们:
- 要创建应用程序,请执行以下操作:
- 开启 MDM 中,转到“应用程序”
- 选择“添加应用程序”。
- 在“编辑应用程序”窗口中,输入所需的信息:
- 名称:在此示例中,使用
Basic App - Android。 - 类型:对于原生应用程序,选择“App”。
- 平台:选择“Android”以自动化 Android 应用程序。
- 应用程序:对于此示例,将以下链接输入到基本 Android 应用程序:
https://uipathtestappsto.blob.core.windows.net/testapps/BasicAppAndroid.apk。 - 应用程序包:输入移动应用程序包,例如
com.example.basicapp。 - 应用程序活动:输入活动实例,例如:
.core.MainActivity。 - 对于其他所需功能,添加
appium:app功能,以确保应用程序按预期运行。
表 1. 其他所需功能 名称 值 appium:appappium:app https://uipathtestappsto.blob.core.windows.net/testapps/BasicAppAndroid.apk - 名称:在此示例中,使用
- 要创建设备,请执行以下操作:
- 转到“设备”,然后选择“添加设备”。
- 为设备命名。在此示例中,使用
Google Pixel 3a GoogleAPI Emulator。 - 设置以下参数:Appium URL、平台、设备名称、平台版本。
- 从您选择的移动设备场提供程序检索参数。在此示例中,我们使用的是 Sauce Labs。
- 要获取 Appium URL,请转到“帐户”,然后转到“用户设置”。复制“驱动程序创建”下的按需 URL。
- 要获取平台、设备名称和平台版本,请转到“自动化”,然后再转到“平台配置器”。选择
Google Pixel 3a GoogleAPI Emulator和Android Emulator version 10.0的功能。在“配置脚本”下,选择您的Appium version。在此示例中,请使用 2.0.0。 - 将 Sauce 实验室中的值复制并粘贴到 MDM 中。
-
- 选择“保存并关闭”。
- 选择“在此设备上启动应用程序”,然后连接该设备与先前创建的应用程序。
要自动化您的首选移动应用程序,请在项目的对象存储库中记录其移动元素。在此示例中,我们创建了一个带有常规主屏幕的“基本应用程序”应用程序,其中包含我们用于自动化的三个用户界面元素。检查以下列表,查看对象存储库的结构如何显示:
- BasicApp
- HomeScreen
- EditText
- SingleClickButton
- VerifyText
- HomeScreen
在 MDM 中配置设备和应用程序后,请开始为自动化编写代码。在开始使用移动自动化 API 之前,您需要使用相应的 API 在所选移动设备和应用程序之间建立连接。
connection is a class that represents the connection that you create between a device and an application, which exposes the APIs that you can use to automate mobile testing scenarios. Visit Connection for more information on creating a connection.
To create a connection, you have a set of dedicated APIs that you can use. In this example, we used the Connect API, with the second overload, which requires the device and application names as Strings.
使用以下步骤创建连接:
- 从
using语句开始,以避免创建单独的变量。 - 在
using语句中,使用第二个重载版本调用连接 API。对于此重载,请输入设备名称和应用程序名称以建立连接。
[TestCase] public void Execute() { using (Connection connection = mobile.Connect( "Google Pixel 3a GoogleAPI Emulator", "Basic App - Android"))[TestCase] public void Execute() { using (Connection connection = mobile.Connect( "Google Pixel 3a GoogleAPI Emulator", "Basic App - Android")) - (可选)出于调试目的,您可以添加一条
Log消息。Log("Connection established");Log("Connection established");
此示例中的自动化流程包括点击某些按钮,获取移动设备屏幕上显示的文本以及滑动滑块控件。这些操作模拟现实生活中的移动自动化场景。
IElementDescriptors. These represent UI elements accessed directly from the Object Repository. In addition to IElementDescriptors, you can use other selector types with Mobile Automation APIs, such as ObjectRepositoryTarget, and SelectorTarget. Visit API selectors to learn how and when to use other selector types.
- Call the Tap API, to click the SingleClickButton
from the Android Basic
App.
// Tap the SingleClickButton connection.Tap(Descriptors.BasicApp.HomeScreen.SingleClickButton); Log("Tapped SingleClickButton ");// Tap the SingleClickButton connection.Tap(Descriptors.BasicApp.HomeScreen.SingleClickButton); Log("Tapped SingleClickButton "); - Use the SetText API to input a specific text into the EditText
field.
string expectText = "Random text"; connection.SetText(Descriptors.BasicApp.HomeScreen.EditText, expectText); Log("Inserted random text");string expectText = "Random text"; connection.SetText(Descriptors.BasicApp.HomeScreen.EditText, expectText); Log("Inserted random text"); - Get the text you previously set, and verify if it matches the text from the
VerifyText UI element. Use the GetText and VerifyExpression
APIs.
var actualText = connection.GetText(Descriptors.BasicApp.HomeScreen.VerifyText); testing.VerifyExpression(expectText == actualText, "EditText validation failed."); SelectorTarget selector = null;var actualText = connection.GetText(Descriptors.BasicApp.HomeScreen.VerifyText); testing.VerifyExpression(expectText == actualText, "EditText validation failed."); SelectorTarget selector = null; - Use the PositionalSwipe API to move the slider control.
PositionalSwipe API 需要两个
Point变量,表示滑动操作的起点和终点。在使用 API 之前创建这些点以增强可读性。// Perform a positional swipe operation to use the slider var startPoint = new Point(226, 304); var endPoint = new Point(296, 304); connection.PositionalSwipe(startPoint, endPoint); Log("Performed Swipe action.");// Perform a positional swipe operation to use the slider var startPoint = new Point(226, 304); var endPoint = new Point(296, 304); connection.PositionalSwipe(startPoint, endPoint); Log("Performed Swipe action.");要获取屏幕位置,请转到 MDM 中的活动连接。将光标悬停在移动屏幕上。这将在 MDM 的左下角显示光标的位置(以像素为单位)。
要按照此快速入门指南中的步骤操作,或者自己尝试,请下载移动自动化 API 快速入门示例。