- 概述
- 用户界面自动化
- 通过用户界面自动化实现自动化的应用程序和技术
- 项目兼容性
- UI-ANA-016 - 拉取打开浏览器 URL
- UI-ANA-017 - 出错时继续 True
- UI-ANA-018 - 列出 OCR/图像活动
- UI-DBP-006 - 容器使用情况
- UI-DBP-013 - Excel 自动化误用
- UI-DBP-030 - 选取器中的禁止变量使用情况
- 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
- 移动自动化
- 发行说明
- 项目兼容性
- Creating variables from selector attributes
- 开始使用移动自动化 API
- Using mobile automation for mobile banking application
- 终端
Using mobile automation for mobile banking application
In this tutorial, we explore how to use the Mobile Automation package to automate tasks within a mobile banking application. The tutorial uses the mobile banking simulator provided by Bank of America, and a Google Pixel Emulator from Sauce Labs. We will specifically focus on automating and testing the following actions:
- Logging into the app.
- Implementing a debit card lock.
- Viewing a claim and capturing a screenshot.
The tutorial provides instructions on how to use both activities and APIs for automating these scenarios.
- Add a device from Sauce Labs into MDM.
For more information about adding devices, visit Adding Sauce Labs device.
- Add the Bank of America mobile banking simulator into MDM.
For more information about adding applications, visit Adding applications.
To follow the steps and try out the tutorial yourself, check the following sample project: Mobile Banking Simulator.
In this example we use Object Repository elements as input UI elements to activities. To create UI elements for mobile, establish a connection in Mobile Device Manager (MDM) between the target device and application. Then, directly in the Object Repository panel, create each element and use Indicate Element to indicate the specific UI element on the MDM device.
To easily follow the tutorial, check the following list for the Object Repository structure:
- BankOfAmerica application, MobileScreen menu
- backFromClaimDetails
- backFromClaimStatus
- BackToMenu
- firstClaimSeeDetails
- Lock
- LockCard
- Login
- ManageDebitCredit
- 菜单
- 密码
- swipeMenu
- 用户 ID
- viewmyclaims
- Establish a connection between the device and application:
- Add a Mobile Device Connection activity.
- Use Select Connection Details to connect the previously created mobile device and application.
- Login to the mobile application:
- Add a Tap activity to select the User ID field, so you can then enter a username.
- Add a Set Text activity to input the username inside the User ID field.
- Add a Tap activity to select the Password field, so you can then enter the password.
- Add a Set Text activity to input the corresponding password.
- Use a Tap activity to select the Login button.
Figure 1. The first activities as part of logging into the application
- Lock a debit or credit card:
- Add a Tap activity to navigate to the mobile banking app menu.
- Add a Swipe activity to swipe down in the menu.
The goal is to swipe until you find the Manage Debit/Credit section.
- Add a Tap activity to select the Manage Debit/Credit section.
- Add a Tap activity to select the Lock icon for the first card that is displayed.
- Add a Swipe activity to swipe down in the lock card notice.
This action allows you to confirm the action by selecting Lock Card.
- Add a Tap activity to select Lock Card.
Figure 2. Activities used for locking the debit card
- Take a screenshot of a claim:
- Add a Tap activity to select the back button, and return to the main menu.
- Add a Swipe activity to swipe down in the main menu, until the View My Claims section appears.
- Use a Tap activity to select the View My Claims section.
- Add a Tap activity to select See details for the first claim.
- Use the TakeScreenshot API to take a screenshot of the first claim details.
Figure 3. Activities used to take a screenshot of a claim
- Finally, after taking the screenshot, we go back to the main menu of the app, by using the Tap activity to select the Back UI element twice.
To automate a mobile application using APIs, record the application mobile elements within the project's Object Repository. For this example, we created a BankOfAmerica application with a general MobileScreen, containing all the UI elements that we use to automate. To create UI elements for mobile, establish a connection in Mobile Device Manager (MDM) between the target device and application. Then, directly in the Object Repository panel, create each element and use Indicate Element to indicate the specific UI element on the MDM device.
Check the following list for the structure of the Object Repository:
- BankOfAmerica application, MobileScreen menu
- backFromClaimDetails
- backFromClaimStatus
- BackToMenu
- firstClaimSeeDetails
- Lock
- LockCard
- Login
- ManageDebitCredit
- 菜单
- 密码
- swipeMenu
- 用户 ID
- viewmyclaims
- Establish a connection between the device and application:
- Create a variable of type
Connection
, using the Connect API, with the second overload version.For this overload, enter the device name and application name as Strings, to establish the connection.
[TestCase] public void Execute() { Connection connection = mobile.Connect( "Android mobile device", "BankOfAmericaSimulator"); Log("Connection established");
[TestCase] public void Execute() { Connection connection = mobile.Connect( "Android mobile device", "BankOfAmericaSimulator"); Log("Connection established");
- Create a variable of type
- Optionally, for debugging purposes, you can add a
Log
message after the connection. - Log in to the mobile application:
- Call the Tap API to click the User ID field.
This action allows you to enter the username.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.UserId);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.UserId); - Use the SetText API to enter a username in the User ID
field.
connection.SetText(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.UserId, "john.doe@uipath.com", MobileOptions.SetText().WithSendNewline(false));
connection.SetText(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.UserId, "john.doe@uipath.com", MobileOptions.SetText().WithSendNewline(false)); - Call the Tap API to
select the Password field so you can enter the
password.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Password);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Password); - Use the Set Text API to enter a password in the Password field.
The
WithSendNewLine(false)
method ensures that the OK keyboard element is not pressed on the mobile device after sending the text. For more information about the available options of the Set Text API, visit MobileOptions.SetTextOptions Class.connection.SetText(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Password, "abcde", MobileOptions.SetText().WithSendNewline(false));
connection.SetText(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Password, "abcde", MobileOptions.SetText().WithSendNewline(false)); - Employ the Tap API to
select
Login.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Login);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Login);
- Call the Tap API to click the User ID field.
- Lock a debit or credit card:
- Navigate to the menu of the mobile banking app, using the Tap
API:
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Menu);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Menu); - Swipe down in the menu, using the Swipe API.
The goal is to swipe until you find the Manage Debit/Credit section.
connection.Swipe(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.swipeMenu, ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.ManageDebitCredit, SwipeDirection.Down, 4);
connection.Swipe(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.swipeMenu, ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.ManageDebitCredit, SwipeDirection.Down, 4); - Select the Manage Debit/Credit section using the Tap API.
The
WithTimeout()
method enables the API to pause for a predetermined number of seconds. This pause lasts until the target UI element appears, or an error is thrown.connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.ManageDebitCredit, TapTypeEnum.Single, MobileOptions.Tap().WithTimeout(120));
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.ManageDebitCredit, TapTypeEnum.Single, MobileOptions.Tap().WithTimeout(120)); - For the first card that
is displayed, select the Lock icon using the Tap
API.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Lock);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.Lock); - Swipe down in the lock
card notice, using the Directional Swipe API, so we can confirm the action by
selecting Lock
Card.
connection.DirectionalSwipe(SwipeDirection.Down);
connection.DirectionalSwipe(SwipeDirection.Down); - Select Lock Card using the Tap
API.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.LockCard);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.LockCard);
- Navigate to the menu of the mobile banking app, using the Tap
API:
- Take a screenshot of a claim.
- Go back to the main menu,
using the Tap API and the back
icon.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.BackToMenu);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.BackToMenu); - Swipe down in the main menu, until the View My Claims section appears.
For this step, we use the Swipe API, this time employing the sixth overload. This overload requires an
IElementDescriptor
for the swipe container, and aSelectorTarget
for the target UI element.We first create aSelectorTarget
for the View My Claims section, and then employ the Swipe API.- Open MDM and create the connection between the mobile device and application.
- Go to the Object Repository and create a new element for the mobile screen.
- Select Indicate element.
- From the selection options menu, copy the web control identified by the selectors.
For this mobile banking app, you have to ensure that WebView selectors as native selectors is selected as a selection option.
- Return to the
code editor, and create a variable of type
SelectorTarget
. Use theMobileTarget.FromSelector
method which requires as argument the web control you previously copied.SelectorTarget viewMyClaimsTarget = MobileTarget.FromSelector("<mbl android:className='android.widget.TextView' text='View My Claims' />");
SelectorTarget viewMyClaimsTarget = MobileTarget.FromSelector("<mbl android:className='android.widget.TextView' text='View My Claims' />"); - Use the Swipe
API, with the
SelectorTarget
variable, to finish the swipe down action.connection.Swipe(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.swipeMenu, viewMyClaimsTarget, SwipeDirection.Down, 20);
connection.Swipe(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.swipeMenu, viewMyClaimsTarget, SwipeDirection.Down, 20);
- Tap the View My
Claims
section.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.viewmyclaims);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.viewmyclaims); - Tap See details
for the first
claim.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.firstClaimSeeDetails);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.firstClaimSeeDetails); - Use the TakeScreenshot API to take a screenshot of the first claim
details.
connection.TakeScreenshot();
connection.TakeScreenshot();
- Go back to the main menu,
using the Tap API and the back
icon.
- Finally, after taking the screenshot, we go back to the main menu of the app, by
tapping the Back UI element
twice.
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.backFromClaimDetails); connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.backFromClaimStatus);
connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.backFromClaimDetails); connection.Tap(ObjectRepository.Descriptors.BankOfAmerica.MobileScreen.backFromClaimStatus);