- Overview
- UI Automation
- Applications and technologies automated with UI Automation
- Project compatibility
- UI-ANA-016 - Pull Open Browser URL
- UI-ANA-017 - ContinueOnError True
- UI-ANA-018 - List OCR/Image Activities
- UI-DBP-006 - Container Usage
- UI-DBP-013 - Excel Automation Misuse
- UI-DBP-030 - Forbidden Variables Usage In Selectors
- UI-PRR-001 - Simulate Click
- UI-PRR-002 - Simulate Type
- UI-PRR-003 - Open Application Misuse
- UI-PRR-004 - Hardcoded Delays
- UI-REL-001 - Large Idx in Selectors
- UI-SEC-004 - Selector Email Data
- UI-SEC-010 - App/Url Restrictions
- UI-USG-011 - Non Allowed Attributes
- UX-SEC-010 - App/Url Restrictions
- UX-DBP-029 - Insecure Password Use
- UI-PST-001 - Audit Log Level in Project Settings
- UiPath Browser Migration Tool
- Clipping region
- Computer Vision Recorder
- Activities index
- Activate
- Anchor Base
- Attach Browser
- Attach Window
- Block User Input
- Callout
- Check
- Click
- Click Image
- Click Image Trigger
- Click OCR Text
- Click Text
- Click Trigger
- Close Application
- Close Tab
- Close Window
- Context Aware Anchor
- Copy Selected Text
- Element Attribute Change Trigger
- Element Exists
- Element Scope
- Element State Change Trigger
- Export UI Tree
- Extract Structured Data
- Find Children
- Find Element
- Find Image
- Find Image Matches
- Find OCR Text Position
- Find Relative Element
- Find Text Position
- Get Active Window
- Get Ancestor
- Get Attribute
- Get Event Info
- Get From Clipboard
- Get Full Text
- Get OCR Text
- Get Password
- Get Position
- Get Source Element
- Get Text
- Get Visible Text
- Go Back
- Go Forward
- Go Home
- Google Cloud Vision OCR
- Hide Window
- Highlight
- Hotkey Trigger
- Hover
- Hover Image
- Hover OCR Text
- Hover Text
- Image Exists
- Indicate On Screen
- Inject .NET Code
- Inject Js Script
- Invoke ActiveX Method
- Key Press Trigger
- Load Image
- Maximize Window
- Microsoft Azure Computer Vision OCR
- Microsoft OCR
- Microsoft Project Oxford Online OCR
- Minimize Window
- Monitor Events
- Mouse Trigger
- Move Window
- Navigate To
- OCR Text Exists
- On Element Appear
- On Element Vanish
- On Image Appear
- On Image Vanish
- Open Application
- Open Browser
- Refresh Browser
- Replay User Event
- Restore Window
- Save Image
- Select Item
- Select Multiple Items
- Send Hotkey
- Set Clipping Region
- Set Focus
- Set Text
- Set To Clipboard
- Set Web Attribute
- Show Window
- Start Process
- System Trigger
- Take Screenshot
- Tesseract OCR
- Text Exists
- Tooltip
- Type Into
- Type Secure Text
- Use Foreground
- Wait Attribute
- Wait Element Vanish
- Wait Image Vanish
- Application Event Trigger
- Check/Uncheck
- Check App State
- Check Element
- Click
- Click Event Trigger
- Drag and Drop
- Extract Table Data
- For Each UI Element
- Get Attribute
- Get Browser Data
- Get Text
- Get URL
- Go to URL
- Highlight
- Hover
- Inject Js Script
- Keyboard Shortcuts
- Keypress Event Trigger
- Mouse Scroll
- Navigate Browser
- Select Item
- Set Browser Data
- Set Runtime Browser
- Set Text
- Take Screenshot
- Type Into
- Use Application/Browser
- Perform browser search and retrieve results using UI Automation APIs
- Web Browsing
- Find Images
- Click Images
- Trigger and Monitor Events
- Create and Override Files
- HTML Pages: Extract and Manipulate Information
- Window Manipulation
- Automated List Selection
- Find and Manipulate Window Elements
- Manage Text Automation
- Load and Process Images
- Manage Mouse Activated Actions
- Automate Application Runtime
- Automated Run of a Local Application
- Browser Navigation
- Web Automation
- Trigger Scope Example
- Enable UI Automation support in DevExpress
- Computer Vision Local Server
- Mobile Automation
- Release notes
- Project compatibility
- Get Log Types
- Get Logs
- Get Page Source
- Get Device Orientation
- Get Session Identifier
- Install App
- Manage Current App
- Manage Other App
- Open DeepLink
- Open URL
- Mobile Device Connection
- Directional Swipe
- Draw Pattern
- Positional Swipe
- Press Hardware Button
- Set Device Orientation
- Take Screenshot
- Take Screenshot Part
- Element Exists
- Execute Command
- Get Attribute
- Get Selected Item
- Get Text
- Set Selected Item
- Set Text
- Swipe
- Tap
- Type Text
- Creating variables from selector attributes
- Getting started with Mobile Automation APIs
- Using mobile automation for mobile banking application
- Terminal
UI Automation Activities
Getting started with Mobile Automation APIs
This Quickstart guide helps you create your first coded automation, using Mobile Automation APIs. The tutorial uses the UiPath® Android Basic App and a Google Pixel Emulator from Sauce Labs for automated testing.
To use the desired mobile device and application within our coded automation, we have to create them first in MDM (Mobile Device Manager):
- To create the application:
- Open MDM, and go to Applications
- Select Add an application.
- In the Edit
application window, input the required information:
- Name: For this example, use
Basic App - Android
. - Type: Select App for a native application.
- Platform: Select Android to automate the Android application.
- App: For this example, input the following link to the
Basic Android App:
https://uipathtestappsto.blob.core.windows.net/testapps/BasicAppAndroid.apk
. - App Package: Enter the mobile application package, such
as
com.example.basicapp
. - App
activity: Input the activity instance, such as:
.core.MainActivity
. - For Additional Desired Capabilities, add the
appium:app
capability, to ensure that the application works as expected.
Table 1. Additional Desired Capabilities Name Value appium:app
appium:app https://uipathtestappsto.blob.core.windows.net/testapps/BasicAppAndroid.apk
- Name: For this example, use
- To create the device:
- Go to Devices, and select Add a device.
- Name the device. For this
example, use
Google Pixel 3a GoogleAPI Emulator
. - Set the following parameters: Appium URL, Platform,
Device Name, Platform Version.
- Retrieve the parameters from your chosen mobile device farm provider. In this example, we're using Sauce Labs.
- To get Appium Url, go to Account then User Settings. Copy the On-demand URL under Driver Creation.
- To get
Platform, Device Name, and Platform
Version, go to Automated then Platform
Configurator. Select the capabilities for
Google Pixel 3a GoogleAPI Emulator
andAndroid Emulator version 10.0
. Under Config Script, choose yourAppium version
. For this example, use 2.0.0. - Copy and paste the values from Sauce Labs into MDM.
-
- Select Save and Close.
- Select Start an application on this device, and connect the device with the previously created application.
To automate your preferred mobile application, record its mobile elements within the project's Object Repository. For this example, we created a Basic App application with a general HomeScreen, containing three UI elements that we use to automate. Check the following list to see how the Object Repository's structure appears:
- BasicApp
- HomeScreen
- EditText
- SingleClickButton
- VerifyText
- HomeScreen
After you configure your device and application in MDM, start writing the code for your automation. Before you start using the Mobile Automation APIs, you need to establish a connection between your chosen mobile device and application, using the corresponding APIs.
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.
Create the connection using the following steps:
- Start with a
using
statement, to avoid creating a separate variable. - Inside the
using
statement, call the Connect API, with the second overload version.For this overload, enter the device name and application name, to establish the connection.
[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")) - Optionally, for debugging purposes, you can add a
Log
message.Log("Connection established");
Log("Connection established");
The automation flow in this example includes tapping certain buttons, getting text that is displayed on the mobile screen, and swiping a slider control. These actions simulate real-life mobile automation scenarios.
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.
The PositionalSwipe API requires two
Point
variables, representing the start and end points for the swipe action. Create these points before using the API for enhanced readability.// 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.");To get the screen position, go to the active connection in MDM. Hover your cursor over the mobile screen. This will display the cursor's location in pixels at the bottom-left corner of the MDM.
To follow the steps in this Quickstart guide, or to try it out yourself, download the Mobile Automation APIs Quickstart sample.