Unified Functional Testing on HP Mobile Center Quick Start

Transcription

Unified Functional Testing on HP Mobile Center Quick Start
HP Mobile Center
Software Version: 1.01 Patch 2
UFT on Mobile Center Quick Start
Document Release Date: 16 March 2015
Software Release Date: February 2015
UFT on Mobile Center Quick Start
Legal Notices
Warranty
The only warranties for HP products and services are set forth in the express warranty statements accompanying such products and services. Nothing
herein should be construed as constituting an additional warranty. HP shall not be liable for technical or editorial errors or omissions contained
herein.
The information contained herein is subject to change without notice.
Restricted Rights Legend
Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial
Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under
vendor's standard commercial license.
Copyright Notice
© Copyright 2015 Hewlett-Packard Development Company, L.P.
Trademark Notices
Adobe® is a trademark of Adobe Systems Incorporated.
Microsoft® and Windows® are U.S. registered trademarks of Microsoft Corporation.
UNIX® is a registered trademark of The Open Group.
Red Hat® is a registered trademark of Red Hat, Inc. in the United States and other countries.
iPad® is a trademark of Apple Inc.
iPhone® is a trademark of Apple Inc.
Google™ © 2012 Google Inc. All rights reserved. Google and the Google Logo are registered trademarks of Google Inc.
Documentation Updates
The title page of this document contains the following identifying information:
l
l
l
Software Version number, which indicates the software version.
Document Release Date, which changes each time the document is updated.
Software Release Date, which indicates the release date of this version of the software.
To check for recent updates or to verify that you are using the most recent edition of a document, go to:
https://softwaresupport.hp.com/group/softwaresupport/home
This site requires that you register for an HP Passport and sign in. To register for an HP Passport ID, go to:
https://passport2.hp.com/hpp/login.do
Or click the New users - please register link on the HP Passport login page.
HP Mobile Center (1.01 Patch 2)
Page 2 of 61
UFT on Mobile Center Quick Start
You will also receive updated or new editions if you subscribe to the appropriate product support service. Contact your HP sales representative for
details.
Support
Visit the HP Software Support Online web site at: https://softwaresupport.hp.com
This web site provides contact information and details about the products, services, and support that HP Software offers.
HP Software online support provides customer self-solve capabilities. It provides a fast and efficient way to access interactive technical support tools
needed to manage your business. As a valued support customer, you can benefit by using the support web site to:
l
l
l
l
l
l
l
l
Search for knowledge documents of interest
Submit and track support cases and enhancement requests
Download software patches
Manage support contracts
Look up HP support contacts
Review information about available services
Enter into discussions with other software customers
Research and register for software training
Most of the support areas require that you register as an HP Passport user and sign in. Many also require a support contract. To register for an HP
Passport ID, go to: https://softwaresupport.hp.com and click Register.
To find more information about access levels, go to:
https://softwaresupport.hp.com/web/softwaresupport/access-levels.
Visit HP Software Solutions Now at https://h20230.www2.hp.com/sc/solutions/index.jsp to explore how the products in the HP
Software catalog work together, exchange information, and solve business needs.
Visit the Cross Portfolio Best Practices Library at https://hpln.hp.com/group/best-practices-hpsw to access a wide variety of best
practice documents and materials.
HP Mobile Center (1.01 Patch 2)
Page 3 of 61
UFT on Mobile Center Quick Start
Contents
Welcome
5
Welcome to Unified Functional Testing (UFT) on HP Mobile Center
6
How do I set up my testing environment?
8
How do I define connections and settings?
11
How do I record test steps?
17
Enhance your UFT tests with Insight
30
Using Insight in a recording session
30
Using Insight in an editing session
30
How do I use Insight while editing a test?
31
How do I edit test steps?
4 tips for enhancing your Android tests using uiAutomatorViewer
35
41
How do I run tests on mobile applications using UFT?
48
How do I use network virtualization?
52
Considerations and Limitations when testing mobile applications
53
Examples of UFT Tests on Mobile Applications
56
Send Us Feedback
HP Mobile Center (1.01 Patch 2)
60
Page 4 of 61
UFT on Mobile Center Quick Start
Welcome
Welcome
HP Mobile Center helps you take control of your mobile reality, and addresses the
challenge of optimizing mobile app quality and user experience throughout the
application lifecycle. Built on native HP technology, HP Mobile Center leverages our
expertise in functional and performance testing, and integrates mobile testing with
Sprinter, Unified Functional Testing, LoadRunner, Performance Center, Network
Virtualization and Business Process Monitoring (powered by HP BSM).
This guide describes how to use UFT to record and run GUI tests on mobile applications
running on real mobile devices hosted on HP Mobile Center.
For full details, check out the HP Mobile Center Help.
HP Mobile Center (1.01 Patch 2)
Page 5 of 61
UFT on Mobile Center Quick Start
Welcome to Unified Functional Testing (UFT) on HP Mobile Center
Welcome to Unified Functional Testing
(UFT) on HP Mobile Center
Use UFT 12.02 Patch 1 to record and run GUI tests and components on real Mobile
devices hosted on HP Mobile Center.
Using UFT's Mobile Add-in, you can create and run tests on native mobile applications
on a variety of devices that run on Android or iOS. UFT connects to HP Mobile Center,
accesses the mobile devices attached to it, interacts with the applications on those
devices, and runs tests on the devices.
What do you want to do?
l
Create and run a test for a mobile application
l
View considerations and limitations when testing mobile applications
l
l
Learn about Mobile Add-in test objects, methods, and properties in the Mobile Add-in
Object Model Reference of the HP Mobile Center online Help
(http://mobilecenterhelp.saas.hp.com)
View code examples of UFT tests on mobile applications
What's New in UFT 12.02 Mobile Patch 1
l
l
HP Jenkins plugin 3.0.7 support is now available. You can use this plugin to trigger
and run UFT tests for mobile applications on real mobile devices that are connected
to the HP Mobile Center server. For details, see: https://wiki.jenkinsci.org/display/JENKINS/HP+Application+Automation+Tools (Also available directly
without this patch)
UFT 12.02 Patch 1: This cumulative patch contains:
n
The full content of UFT 12.02 Mobile Patch (UFTMOB_00003 - HP Unified
Functional Testing 12.02 Mobile Patch)
n
All of the ALM-related fixes that are included in the UFT Add-in for ALM 12.02
Patch 1
HP Mobile Center (1.01 Patch 2)
Page 6 of 61
UFT on Mobile Center Quick Start
Welcome to Unified Functional Testing (UFT) on HP Mobile Center
n
l
Support for the following new browser versions, for web testing via UFT:
o
Support for Chrome, version 40, 41 (beta)
o
Support for Firefox, version 35, 36 (beta)
Bug fixes
HP Mobile Center (1.01 Patch 2)
Page 7 of 61
UFT on Mobile Center Quick Start
How do I set up my testing environment?
Make sure the prerequisites are met. HP Mobile Center (1.01 Patch 2)
Page 8 of 61
UFT on Mobile Center Quick Start
HP Mobile Center setup & application preparation
Learn how
HP Mobile Center must already be
set up with the devices you want to
test.
Go to the HP Mobile Center Help:
http://mobilecenterhelp.saas.hp.com
l
l
l
HP Mobile Center must be
installed on a Red Hat 6.5
machine.
Mobile devices must be
connected to the HP Mobile
Center server.
UFT must be able to connect to
HP Mobile Center.
If you are testing native mobile
applications running on iOS or
hybrid applications, instrument
your applications for testing
BEFORE using UFT to upload
these applications to HP Mobile
Center.
Go to the HP Mobile Center Help:
http://mobilecenterhelp.saas.hp.com
Browser cookies must be enabled.
--
HP Mobile Center (1.01 Patch 2)
Page 9 of 61
UFT on Mobile Center Quick Start
HP Mobile Center setup & application preparation
Learn how
Internet Explorer Compatibility
View settings must be disabled.
In Tools > Compatibility View
Settings, clear:
l
l
Display all websites in
Compatibility View
Display intranet sites in
Compatibility View
In UFT, load the Mobile Add-in.
1. Open UFT.
2. In the Add-in Manager dialog box, select the Mobile add-in.
HP Mobile Center (1.01 Patch 2)
Page 10 of 61
UFT on Mobile Center Quick Start
How do I define connections and settings?
Prerequisites:
l
l
Internet Explorer (IE) 10 or later must be installed on the UFT computer.
Clear the browser cache on the UFT computer before working with HP Mobile
Center.
1. In UFT, define the connection details for HP Mobile Center via UFT's Options dialog
box.
a. Select Tools > Options > GUI Testing tab to open the Options dialog box.Then,
in the side bar, select Mobile. The HP Mobile Center connection settings pane
opens.
HP Mobile Center (1.01 Patch 2)
Page 11 of 61
UFT on Mobile Center Quick Start
b. Enter the connection details and test the connection:
Server
address
IP or DNS address of your HP Mobile Center server,
including access port.
Default port: 8080
User name
Login credentials for the HP Mobile Center server.
& Password
Test
Connection
Click to ensure that the connection details are correct and
that UFT can reach the HP Mobile Center server.
2. Specify the application and device that you want to test via UFT's Record and Run
Settings.
You can save different settings for different tests, creating a test set that covers a
variety of devices and applications.
a. Create or open a GUI test or a component.
b. Define the record and run settings:
Note: This step requires communication with the HP Mobile Center server
defined above. If the server is not defined correctly or is not accessible,
applications and/or devices are not available in the Record and Run Settings
and an icon ( ) is displayed next to the relevant browse button. Hover
over the icon for details.
HP Mobile Center (1.01 Patch 2)
Page 12 of 61
UFT on Mobile Center Quick Start
GUI test
In UFT, select Record > Record and Run Settings, and
select the Mobile pane. Show me
Component In UFT, open the component's application area, expand the
Additional Settings tab, and select the Mobile tab. Show
me
Note: The settings in an application area are limited to
include one device and one application only. If you
need to test multiple devices or multiple applications,
create different application areas for each device and/or
application.
HP Mobile Center (1.01 Patch 2)
Page 13 of 61
UFT on Mobile Center Quick Start
c. Select the Record and run on a device connected to the mobile lab option.
d. Enter the following details:
The first time you select an application and device, you must click the Browse
button and select the appropriate application or device from the HP Mobile
Center dialog boxes that open. After the first selection, you can select the
application or device from the drop-down menu.
HP Mobile Center (1.01 Patch 2)
Page 14 of 61
UFT on Mobile Center Quick Start
Application
To test a non-web
application:
Select it from the list or browse
and upload (add) it. When
adding an application, make
sure the application is
instrumented, if relevant.
Note: The list of applications
is read-only, even though it
appears to be editable.
To test a web
application:
o
Select any application now.
(In this dialog box, you cannot
select or upload a web
application.)
Later, when UFT starts the
record session on the mobile
device, open the web browser
on the device and navigate to
the web application.
o
Use Insight (see instructions)
Note: Although you can upload multiple instances of
the same version of an application, when you select
an application to test, UFT always tests the first
instance you uploaded for a specific version.
Therefore, to test an application instance with different
content, make sure it is labeled with a different version
number before you upload it to HP Mobile Center.
HP Mobile Center (1.01 Patch 2)
Page 15 of 61
UFT on Mobile Center Quick Start
Device
Select from the devices installed on HP Mobile Center.
Note:
Mobile
vitals
o
Only devices that can run the selected application
are displayed in the list.
o
The list of devices is read-only, even though it
appears to be editable.
(Optional) Specify the data to collect from the mobile
device during a run session, for example, details on the
mobile device's CPU, memory, and free memory.
e. Specify the system actions to perform on the application at the beginning and
end of each run session.
Restart
application
before run
Restarts the application before the record or run session
begins, regardless of the application's current state.
Install
application
before run
Installs the application before the record or run session
begins (or re-installs the application if already installed
on the device).
Uninstall
application
after run
Uninstalls the application after a record or run session,
according to your selection:
o
If the run passed
Caution: The application is uninstalled even if a
checkpoint step fails or the test includes a
Reporter.ReportEvent step.
o
HP Mobile Center (1.01 Patch 2)
Always
Page 16 of 61
UFT on Mobile Center Quick Start
How do I record test steps?
How do I record a GUI test or component?
Prerequisites:
l
l
Make sure that connections to the HP Mobile Center are defined and that the
record and run settings are configured. For details, see "How do I define
connections and settings?" on page 11.
iOS applications and hybrid Android applications must be pre-instrumented.
For details, see Prepare your apps for upload in the HP Mobile Center online Help
(http://mobilecenterhelp.saas.hp.com).
Record steps that you perform on native applications on the mobile device
1. Select Record > Record to start a recording session. A remote access window
opens, connected to the device you specified.
HP Mobile Center (1.01 Patch 2)
Page 17 of 61
UFT on Mobile Center Quick Start
2. Interact with the mobile device by clicking the user interface in the remote access
window.
You can:
n
Perform a sequence of operations that you want to test.
n
Click on various objects in your application so that they get added to the object
repository.
Then you can delete the recorded steps and create other ones with the added
objects.
UFT records the operations you perform and adds the test objects to the object
repository.
Note:
n
If the remote access window fails to complete the loading of the user
interface, UFT continues to interact with the mobile device itself, recording
steps that you perform on the device. (If this occurs, Insight is not supported
because Insight relies on the remote access window and does not interact
with the device itself.)
HP Mobile Center (1.01 Patch 2)
Page 18 of 61
UFT on Mobile Center Quick Start
n
The Send Application to Background option in the Options sidebar menu (in
the remote access (RDP) window), is not supported.
Android only:
n
On the left side of the remote access window, you can switch the Mobile
Center to Analog recording mode. This means that only Device.Touch steps
are recorded, according to the locations at which you touch the device.
This is different from UFT's analog recording mode, which is available in the
Record toolbar, and results an analog recording track on the remote access
window itself (Window("samsung Nexus 10").RunAnalog "Track1").
n
When recording, the Home, Back, and RecentApps buttons displayed on the
remote access windows without physical buttons are not supported. To
record a step that uses one of these buttons, open the Options sidebar menu
on the left side of the HP Mobile Center window and click the required
button.
3. Click Stop to stop the recording session.
Record Insight steps to test web applications on your mobile device.
1. Select Record > Record to start a recording session. A remote access window
opens, connected to the device you specified.
2. In the remote access window, tap the device's Home button.
How do I do this on Android?
a. Open the Options sidebar menu on the left side of the remote access window.
b. Click the Home button.
HP Mobile Center (1.01 Patch 2)
Page 19 of 61
UFT on Mobile Center Quick Start
3. In the Record Toolbar, in the Recording Mode drop down list, select Insight
Recording.
4. In the remote access window, in the mobile device, launch the device browser and
navigate to the web application you want to test.
5. Record the necessary steps on the device's browser. While you record, UFT adds
steps and objects to the test and object repository, respectively. Each object you
use is recognized as an InsightObject.
6. Click Stop to stop the recording session.
Example:
Device("Device").Home
Device("Device").InsightObject(
Device("Device").InsightObject(
).Click
).Click
How do I record a test on multiple devices?
1. Create a unique test object for the first device.
a. Set the record and run settings for the first application and device.
b. Record steps on the device, as described above.
c. Stop recording.
d. Define the first device-specific test object in the object repository:
i. Open the Object Repository window. For instructions on working with the
Object Repository window, see the UFT documentation.
HP Mobile Center (1.01 Patch 2)
Page 20 of 61
UFT on Mobile Center Quick Start
ii. Select the Device test object and rename it with a descriptive name, such
as Device1.
iii. In the test, verify that the test steps are updated with the <Device1> test
object.
iv. In the Object Repository window > Test Object Details pane, select
<Device1> and click
to open the Add Properties dialog box.
v. Add the id description property and value for <Device1>.
Tip: To enable flexibility, bind the id description property to an
Environment variable or Data Table parameter.
vi. Verify that the value of the id description property is the device ID of
Device1.
2. Repeat step 1 for every additional device (using a unique name and description).
3. Create a function that brings the remote access window displaying the device to
the foreground.
Add the following code to the test or a function library.
'@Description Activate the remote access window for the device
Public Function Device_ActivateRemoteWindow(ByRef device)
raWindowHwnd = device.GetROProperty("hwnd")
Window("is child window:=False", "hwnd:=" &
raWindowHwnd).Activate
End Function
RegisterUserFunc "Device", "ActivateRemoteWindow", "Device_
ActivateRemoteWindow"
4. Insert a step to call Device.ActivateRemoteWindow PRIOR to the steps
performed on every device, except for the first device.
HP Mobile Center (1.01 Patch 2)
Page 21 of 61
UFT on Mobile Center Quick Start
How do I record a test on multiple applications? (Android only)
1. Set the record and run settings for the first application and device.
2. Record steps on the first application, as described above.
3. Modify the record and run settings to specify the next application on which to
record.
4. Record steps on the next application, as described above.
5. Edit the test to insert steps BETWEEN the steps on each application. This forces the
opening of that application and brings it to the foreground.
If your test needs to open MORE than one application during a run session, you
must add steps that open each application separately and bring the application to
the foreground.
You can do this in one of the following ways:
n
Option 1: Use Insight recording. (Android only)
i. In your test, position the cursor prior to the steps on the next application.
ii. Select Record > Record to start a recording session. A remote access
window opens, connected to the device you specified.
iii. Record a Home step:
A. Open the Options sidebar menu on the left side of the remote access
window.
B. Click the Home button.
iv. Select Insight Recording from the Record toolbar's Recording Mode dropdown list.
HP Mobile Center (1.01 Patch 2)
Page 22 of 61
UFT on Mobile Center Quick Start
v. Record steps that open the relevant application.
vi. Stop recording.
Example:
Device("Device").Home
Device("Device").InsightObject(
Device("Device").InsightObject(
n
).Click
).Click
Option 2: Use uiAutomatorViewer (Android only)
i. Use uiAutomatorViewer to identify the device's application launcher and
then create an App test object.
A. Use uiAutomatorViewer to scan the view that contains your
application. For instructions, see " Analyze your application's user
interface (Android only)" on page 41.
B. Note the value of the package property.
C. In UFT, create a test object to represent the application.
A. Open the Object Repository window. For instructions on working
with the Object Repository window, see the UFT documentation.
B. In the Object Repository window, select the relevant Device test
object.
C. Create a new child test object (Object > Define New Test Object)
and assign it unique description properties.
HP Mobile Center (1.01 Patch 2)
Page 23 of 61
UFT on Mobile Center Quick Start
A. In the Define New Test Object dialog box, define the following:
Class
App
Name
A unique name for the test object.
Best practice: Assign a descriptive name
that indicates the application's name or
purpose.
Test object details
Description
properties
A. Remove all properties EXCEPT for
identifier.
B. For identifier, enter the value you
noted from the uiAutomatorViewer
package property.
B. Click
to open the Add Properties dialog box.
C. In the Add Properties dialog box, click
Property dialog box.
to open the New
D. In the New Property dialog box, add a systemApp property
with the value True.
ii. Create a MobileView test object for the next application's icon.
A. Prerequisite: Scan the views in your application that contain the
objects you want to add to the object repository. For instructions, see "
Analyze your application's user interface (Android only)" on page 41.
B. For each object that you want to add, note the values for following
properties:
l
"class" on page 43
l
"content-desc" on page 42
l
"text" on page 42
C. In UFT, create a test object to represent each object that you want to
HP Mobile Center (1.01 Patch 2)
Page 24 of 61
UFT on Mobile Center Quick Start
add:
A. Open the Object Repository window. For instructions on working
with the Object Repository window, see the UFT documentation.
B. In the Object Repository window, select the Test Object root node.
C. Create a new child test object (Object > Define New Test Object)
and assign it unique description properties. In the Define New Test
Object dialog box, define the following:
Class
MobileView
Name
A unique name for the test
object.
Best practice: Assign a
descriptive name that
indicates the use of the
object.
Test object details: Description properties
HP Mobile Center (1.01 Patch 2)
Page 25 of 61
UFT on Mobile Center Quick Start
A. Remove all properties EXCEPT for class, text, and
accessibilityid.
B. Modify the remaining property values:
class: Enter the value you noted from the
uiAutomatorViewer "class" on page 43 property.
accessibilityid: Enter the value you noted from the
uiAutomatorViewer "content-desc" on page 42 property,
if any.
text: Enter the value you noted from the
uiAutomatorViewer "text" on page 42 property, if any.
index: (Optional) If the "content-desc" on page 42
property value is empty AND the "text" on page 42
property value is empty or dynamic (meaning it changes
according to the current context), create and set an
index property value by counting the number of objects
of this type in the current view, from top to bottom,
starting from 0.
Note: It may take several tries to set this property
value accurately.
To determine the required index:
A. In the application, position the relevant page in the
foreground.
B. In the Script Editor, enter the following loop
statement:
For i = 0 To X Step 1 'X should be the
estimated number of labels on the screen'
print i & “- “ & Device.App.MobileView
(“class:=Label”, _
HP Mobile Center (1.01 Patch 2)
Page 26 of 61
UFT on Mobile Center Quick Start
“index:=“ & i) _
.GetROProperty(“text”)
Next
C. In UFT's Record & Run Settings, make sure that the
"Install application before run" and "Restart
application before run" check boxes are not
selected. (Otherwise, the application's start page will
be displayed during the run session instead of the
page you selected in step A above.)
D. Run step B above to retrieve the ROProperty value.
E. Look in UFT's Output pane for the index of the label
that contains the value. Use this index to identify the
test object by adding a step similar to the following
example to the test.
currentQuote = Device.App.MobileView
(“class:=Label”, “index:=N“) _
.GetROProperty(“text”)
D. Drag the newly created test object under the relevant App test object.
iii. Manually insert steps in the test to open the next application prior to the
steps recorded on that application.
Example:
Device("Device").Home
Device("Device").App("Launcher").MobileView("App2").Tap
What happens when a recording session starts?
1. If "Install application before run" on page 16 is selected in the record and run
settings, HP Mobile Center installs (or re-installs) the selected application on the
selected device.
HP Mobile Center (1.01 Patch 2)
Page 27 of 61
UFT on Mobile Center Quick Start
UFT displays an error if:
n
The selected device is not available (not connected or locked to another test).
n
The selected application is not available on the server.
n
The installation fails.
2. HP Mobile Center opens the selected application on the selected device.
If "Restart application before run" on page 16 is selected in the record and run
settings, HP Mobile Center restarts the application before opening it.
UFT displays an error if:
n
The selected device is not available (not connected or locked to another test).
n
The selected application is not available on the device.
3. A remote access window opens, displaying the device. The actual device is reserved
for use by HP Mobile Center for the duration of the session so that only UFT can
perform actions on it.
4. UFT records the actions performed on the application.
For a list of supported test objects and methods, see the of the HP Mobile Center online
Help (http://mobilecenterhelp.saas.hp.com).
What happens when a recording session ends?
l
The remote access (RDP) window closes.
l
HP Mobile Center closes the application on the device.
l
l
If "Uninstall application after run" on page 16 is selected in the record and run
settings, HP Mobile Center uninstalls the application from the device.
The device remains reserved for use by HP Mobile Center so that you can continue
working with the device.
Test Objects in the object repository
During a recording session, UFT adds the mobile test objects to the object repository as
it does in any other technology. You can then fine-tune the objects in the object
repository and modify the test steps manually, if necessary.
HP Mobile Center (1.01 Patch 2)
Page 28 of 61
UFT on Mobile Center Quick Start
Identification properties
l
l
Unlike other technologies, UFT may also add some hidden identification properties
when the values are too complex to display or edit. Do not change the values of the
identification properties, as this may cause unexpected results—some hidden
properties may contradict the values of the changed properties. Similarly, using
Programmatic Descriptions may cause unexpected results because some
identification properties may be missing.
The Ordinal Identifier property of mobile test objects is not used. Instead, HP Mobile
Center uses a standard description property called index.
Checkpoints and output values
During a recording session, you can add Standard and Bitmap Checkpoints and Output
Values only to Device test objects.
You can add Checkpoints or Output Values to other mobile test objects during an editing
session.
Insight recording mode
Insight (image-based recording) is supported. All Insight test objects are added under
the parent Device test object. For instructions, see "Record Insight steps to test web
applications on your mobile device." on page 19.
Learn more! "Enhance your UFT tests with Insight" on page 30
Analog recording mode
UFT's Analog Recording is supported. You can also perform analog recording on the
device level (touch actions) using the Options sidebar menu in the remote access
window.
Other recording modes
UFT's Low-Level Recording is not supported.
HP Mobile Center (1.01 Patch 2)
Page 29 of 61
UFT on Mobile Center Quick Start
Enhance your UFT tests with Insight
Insight is a technology-agnostic solution that identifies controls (objects) in your
application visually as they appear on your screen instead of via their properties or
technology. Using Insight enables UFT to capture images and run steps on controls that
might otherwise be unavailable during a record and run session.
Tip: For full and updated details on working with Insight test objects, see the UFT
documentation. To see a demonstration of this functionality, go to the HP Live
Network (HPLN) page and select the Insight movie from the list.
Using Insight in a recording session
When you record a test, Insight test objects are added as child test objects under the
Device test object for the remote access window.
How do I record using Insight?
1. Start recording a test.
2. Select Insight Recording from the Record toolbar's Recording Mode drop-down
list.
3. Record the relevant steps.
Using Insight in an editing session
When editing a test in UFT, your application is not visible in the remote access window.
Therefore, you must prepare your images in advance using a capture tool.
HP Mobile Center (1.01 Patch 2)
Page 30 of 61
UFT on Mobile Center Quick Start
How do I use Insight while editing a test?
1. Capture your application's pages (or just the relevant controls in your application)
using a screen capture / snipping tool.
2. In UFT, record steps on the captured images. The test objects are added to the
object repository under a Window test object parent representing the tool in which
your screen capture is displayed.
3. Modify the image and its properties in the object repository, if needed.
Edit the
image
In UFT, open the object repository and edit the image and its
properties as needed. For example, you can modify the
properties or replace the captured image (using the Change
Test Object Image dialog box).
Set the
similarity
ranking
By default, UFT looks for images in your application that are at
least 80% identical to the stored test object.
To modify this value, add a similarity identification property
to the test object and set it to the required value.
a. In the Object Repository window, select the relevant Insight
test object.
b. In the Test object image area, click
Properties dialog box.
to open the Add
c. Select the similarity identification property and click OK.
d. In the Test object details area of the Object Repository
window, click in the value cell for similarity and set it to
the required value.
This property is a percentage that specifies how similar a
control in the application has to be to the test object image for it
to be considered a match, for example, 100=exact match.
HP Mobile Center (1.01 Patch 2)
Page 31 of 61
UFT on Mobile Center Quick Start
Set areas
to ignore
If your image has areas that change dynamically (such as, the
numerical display area on a calculator, text in a text box, or
labels that change according to the user interface language),
you can instruct UFT to ignore these areas when it searches
for and identifies the image on the screen during a run session.
Note: If you define an excluded area in a test object image,
the similarity identification property value changes to
100 for an exact match. You can modify the similarity
value, if needed.
To define areas to ignore:
a. Select an Insight test object in the Object Repository
window or Object Repository Manager.
b. In the Test object image area, click the Change Test
Object Image button.
c. Click the Select area to exclude
button in the Exclude
Areas toolbar. The mouse pointer changes to a crosshair.
d. Draw a rectangle within the test object image to select the
area to ignore.
HP Mobile Center (1.01 Patch 2)
Page 32 of 61
UFT on Mobile Center Quick Start
Use the
GetVisible
Text
method
You can use the InsightObject.GetVisibleText method to
retrieve text from the screen. This method uses optical
character recognition (OCR) to get text from a rectangle within
the matched image.
To retrieve parameters for text area coordinates from an image:
a. Select an Insight test object in the Object Repository
window or Object Repository Manager.
b. In the Test object image area, click the Change Test
Object Image button.
c. Exclude the area containing the text you want to retrieve.
(See "Set areas to ignore" on the previous page.)
Note: Make sure you also exclude any other areas that
may prevent UFT from recognizing the test object
during a run session.
d. Click the Text Area Helper
button.
e. Draw a rectangle around the area you excluded (where the
text you want to retrieve will be displayed during a run
session). The syntactically correct parameters for the text
area are displayed in a box next to the Text Area Helper
button in the following format: ([Left], [Top], [Right], [Bottom])
f. Copy the parameters and insert them in an
InsightObject.GetVisibleText step.
Use
ImgSrc in
a
programm
atic
descriptio
n
You can use an Insight object in programmatic description, for
example:
Device("D").InsightObject("imgSrc:=<path to image
file on disk>").Click
4. In the object repository, copy the Insight test object to the tree under the relevant
Device test object. This enables UFT to locate the image in the remote access
HP Mobile Center (1.01 Patch 2)
Page 33 of 61
UFT on Mobile Center Quick Start
window during a run session.
HP Mobile Center (1.01 Patch 2)
Page 34 of 61
UFT on Mobile Center Quick Start
How do I edit test steps?
Note: All of the items on this page are optional.
Add non-recordable steps
l
l
l
You can simulate incoming calls or SMSs. UFT records most operations and gestures
that you perform on the mobile applications. To do this, you can add test objects
(such as MobileView) and operations to your test manually. For example, using the
Device test object, you can insert calls to IncomingCall, IncomingSMS, and
GPSRelocate that simulate events that occur on a real mobile device.
You can add flow control statements, such as For and While loops, and If
branches.
You can add steps to test that your application responds correctly to the operations
performed by the test:
n
Use the Exist method to verify that the application displays the controls you
expect.
n
Use the GetROProperty method to retrieve the value of properties such as text,
and then check the value of this property.
n
Use the Reporter.ReportEvent method to send data to the run results.
For example:
Dim ConfirmationExists, DirectFlight, FlightPrice
Device("Device").App("com.flight.mobile").MobileButton
HP Mobile Center (1.01 Patch 2)
Page 35 of 61
UFT on Mobile Center Quick Start
("Reserve").Tap
' check confirmation
ConfirmationExists = Device("Device").App
("com.flight.mobile").MobileObject("Confirm").Exist(10)
If ConfirmationExists Then
' verify that the flight is direct
DirectFlight = Device("Device").App
("com.flight.mobile").MobileCheckbox("Direct").GetROProperty
("isChecked")
If DirectFlight Then
' verify price
FlightPrice = Device("Device").App
("com.flight.mobile").MobileCheckbox("Direct").MobileLabel
("Price").GetROProperty("text")
If FlightPrice = Param_ExpectedPrice Then
Reporter.ReportEvent micPass, "Reserve Flight",
"Direct flight reserved. Price: " & FlightPrice
Else
Reporter.ReportEvent micFail, "Reserve Flight",
"Unexpected price: " & FlightPrice
End If
Else
Reporter.ReportEvent micFail, "Reserve Flight",
"Flight not direct!"
End If
Else
Reporter.ReportEvent micFail, "Reserve Flight", "Flight
not confirmed"
End If
See the Object Model Reference for details on the objects, methods, and properties that
you can use in UFT GUI tests running on mobile devices: HP Mobile Center online help
(http://mobilecenterhelp.saas.hp.com).
Manually add test objects to the object repository
You can define new test objects (Object > Define New Test Object) and modify existing
ones.
HP Mobile Center (1.01 Patch 2)
Page 36 of 61
UFT on Mobile Center Quick Start
Add Checkpoint or Output Value steps to your test
After a recording
session
You can add Standard Checkpoints or Output Values to
any object in your test.
During a
recording session
You can add Standard or Bitmap to the Device object and
Standard Output Values.
These checkpoints enable you to check an object's properties or to capture values that
you want to use later in the test.
To add a checkpoint or output value:
HP Mobile Center (1.01 Patch 2)
Page 37 of 61
UFT on Mobile Center Quick Start
1. Do one of the following:
After a
recording
session
Right-click an object in a test step and select Insert Standard
Checkpoint or Insert Output Value.
During a
recording
session
a. In the Record Toolbar, click the Insert Checkpoint or
Output Value button and select Standard Checkpoint,
Bitmap Checkpoint, or Standard Output Value.
b. Click the device in the remote access window.
c. In the Object Selection dialog box, select the Device test
object and click OK.
2. In the Checkpoint Properties dialog box or Output Value Properties dialog box,
specify the settings for the checkpoint object or output value step:
HP Mobile Center (1.01 Patch 2)
Page 38 of 61
UFT on Mobile Center Quick Start
3. To reuse a checkpoint or output value step, select Design > Checkpoint > Existing
Checkpoint or Design > Output Value > Existing Output Value.
For more details on checkpoints and output values, see the UFT documentation.
Synchronize a test
Launch
You can use the App test object's Launch method to open an
application without performing any steps on it. For example,
you may want to use the Launch method if it takes a long time
to open an application, and this causes the 1st step to fail
because the object is not found.
To use the Launch method, insert a Launch step as the first
step on a device.
Wait
You can insert the VBScript Wait statement between steps to
ensure that the previous step is completed before running the
next step.
You can use the WaitProperty step to instruct UFT to wait
WaitProperty until a specified runtime property is set to a specific value (or
until an optional timeout expires). You can find the list of
supported runtime properties under each of the test object
sections in theHP Mobile Center online help
(http://mobilecenterhelp.saas.hp.com).
Exist
You can use the Exist method to wait until the specified test
object is found in the current view (or until an optional timeout
expires).
Tip: You can also use InsightObject.Exist method.
Make sure that the parent test object is the Device test
object.
Considerations when editing tests
l
UFT does not have a runtime object that can be bound to the mobile test object.
Therefore, any UFT action that takes values from the bounded runtime object will
not have values. For example:
HP Mobile Center (1.01 Patch 2)
Page 39 of 61
UFT on Mobile Center Quick Start
l
l
n
When adding description properties to the object repository, initial values are
either blank or they have default values (for example, Boolean property values
such as True/False).
n
When adding a standard checkpoint, initial property values are blank.
Device test object:
n
Exist checks if the device is connected to the current HP Mobile Center server.
n
Values of location runtime properties (abs_x, abs_y, height and width) are taken
from the corresponding remote access window. Values of other runtime
properties are taken from the HP Mobile Center device details.
App test object:
n
Exist checks if the application is loaded to the current HP Mobile Center server.
n
Values of runtime properties are taken from the HP Mobile Center application
details.
Learn more!
l
"4 tips for enhancing your Android tests using uiAutomatorViewer" on page 41
l
"Enhance your UFT tests with Insight" on page 30
HP Mobile Center (1.01 Patch 2)
Page 40 of 61
UFT on Mobile Center Quick Start
4 tips for enhancing your Android tests using
uiAutomatorViewer
uiAutomatorViewer is an Android SDK tool that scans and analyzes the GUI components
in an Android application. You can use this tool to detect the runtime properties of user
interface elements. This can help you create unique descriptions (a subset of test object
identification properties), for your mobile test objects.
You can use uiAutomatorViewer to:
l
" Analyze your application's user interface (Android only)" below
l
" Add non-recordable objects to the object repository (Android only)" on page 43
l
l
" Add a programmatic description instead of using a test object from an object
repository (Android only)" on page 46
"Add an App (application) test object to the object repository (Android only)" on
page 46
Analyze your application's user interface (Android only)
1. Prerequisites: Make sure that the Android SDK is installed. (The version should be
the same as or newer than the Android version on the device being tested.)
2. Connect an Android device to your Windows computer.
3. Open a terminal window and run: <android-sdk>/tools/uiautomator.bat
4. Take a screenshot of your user interface.
a. Make sure the view you want to scan is clearly displayed in the foreground.
b. In uiAutomatorViewer, click the Device Screenshot
button. If more than one
device is connected, a list is displayed. Select the relevant device.
5. View the results. Example
HP Mobile Center (1.01 Patch 2)
Page 41 of 61
UFT on Mobile Center Quick Start
The left pane contains a snapshot of the view. The top-right pane contains a tree
displaying all test objects recognized in the view. You can:
n
Select a node in the tree to highlight the corresponding object with a red
rectangle in the snapshot.
n
Click an object in the snapshot to highlight the corresponding node in the tree.
When a node in the tree is highlighted, its details and properties are displayed in
the lower-right pane.
The following properties are relevant when working with UFT:
Property
Description
package
The identifier of the application currently in view. Mapped to the
identifier property of the App test object.
text
The text property of the object (usually available for TextView
objects).
contentdesc
The accessibilityid property of the object.
bounds
The bounding rectangle for the object in the application.
scrollable Specifies if the control is a scrollable view.
HP Mobile Center (1.01 Patch 2)
Page 42 of 61
UFT on Mobile Center Quick Start
Property
Description
class
Mapped to the class property of the test object. Examples:
Android class
HP Mobile Center class
android.widget.TextView
Label
android.widget.ImageButton
ImageButton
Add non-recordable objects to the object repository (Android only)
During a recording session, UFT adds test objects to the object repository as you
perform actions on controls in the user interface. Not all objects are recordable, though,
so you may need to add some objects, such as TextView and Image, to the object
repository manually. After you add a test object to the object repository, you can use it
like any other test object.
Not what you need? You can use programmatic descriptions instead.
1. Scan the views in your application that contain the objects you want to add to the
object repository. For instructions, see " Analyze your application's user interface
(Android only)" on page 41.
2. For each object that you want to add, note the values for following properties:
n
"class" above
n
"content-desc" on the previous page
n
"text" on the previous page
3. In UFT, create a test object to represent each object that you want to add:
a. Prerequisite: Scan the views in your application that contain the objects you
want to add to the object repository. For instructions, see " Analyze your
application's user interface (Android only)" on page 41.
b. For each object that you want to add, note the values for following properties:
o
"class" above
o
"content-desc" on the previous page
HP Mobile Center (1.01 Patch 2)
Page 43 of 61
UFT on Mobile Center Quick Start
o
"text" on page 42
c. In UFT, create a test object to represent each object that you want to add:
i. Open the Object Repository window. For instructions on working with the
Object Repository window, see the UFT documentation.
ii. In the Object Repository window, select the Test Object root node.
iii. Create a new child test object (Object > Define New Test Object) and
assign it unique description properties. In the Define New Test Object
dialog box, define the following:
Class
MobileView
Name
A unique name for the test object.
Best practice: Assign a
descriptive name that indicates
the use of the object.
Test object details: Description properties
HP Mobile Center (1.01 Patch 2)
Page 44 of 61
UFT on Mobile Center Quick Start
A. Remove all properties EXCEPT for class, text, and
accessibilityid.
B. Modify the remaining property values:
class: Enter the value you noted from the uiAutomatorViewer
"class" on page 43 property.
accessibilityid: Enter the value you noted from the
uiAutomatorViewer "content-desc" on page 42 property, if any.
text: Enter the value you noted from the uiAutomatorViewer
"text" on page 42 property, if any.
index: (Optional) If the "content-desc" on page 42 property
value is empty AND the "text" on page 42 property value is
empty or dynamic (meaning it changes according to the current
context), create and set an index property value by counting the
number of objects of this type in the current view, from top to
bottom, starting from 0.
Note: It may take several tries to set this property value
accurately.
To determine the required index:
A. In the application, position the relevant page in the
foreground.
B. In the Script Editor, enter the following loop statement:
For i = 0 To X Step 1 'X should be the estimated
number of labels on the screen'
print i & “- “ & Device.App.MobileView
(“class:=Label”, _
“index:=“ & i) _
.GetROProperty(“text”)
Next
C. In UFT's Record & Run Settings, make sure that the "Install
HP Mobile Center (1.01 Patch 2)
Page 45 of 61
UFT on Mobile Center Quick Start
application before run" and "Restart application before run"
check boxes are not selected. (Otherwise, the application's
start page will be displayed during the run session instead
of the page you selected in step A above.)
D. Run step B above to retrieve the ROProperty value.
E. Look in UFT's Output pane for the index of the label that
contains the value. Use this index to identify the test object
by adding a step similar to the following example to the test.
currentQuote = Device.App.MobileView
(“class:=Label”, “index:=N“) _
.GetROProperty(“text”)
d. Drag the newly created test object under the relevant App test object.
Add a programmatic description instead of using a test object from an object
repository (Android only)
Examples:
Instead of using a test object from the object repository
Device("D").App("A").MobileView("class:=Label",
"accessibilityid:=sum").Tap
Not what you need? You can add a test object to the object repository instead.
Instead of using a MobileView test object for scrolling
Device("D").App("A").MobileView
("isscrollable:=True","index:=2").ScrollOnePage "forward"
Add an App (application) test object to the object repository (Android only)
Sometimes, you may need to run steps on an application that cannot be loaded on the
HP Mobile Center server, for example, a system application. In this case, you can add an
application test object to the object repository to represent the application that cannot
HP Mobile Center (1.01 Patch 2)
Page 46 of 61
UFT on Mobile Center Quick Start
be loaded. After you create the application test object, you can add mobile test objects
under it and use these test objects in your test.
1. Use uiAutomatorViewer to scan the view that contains your application. For
instructions, see " Analyze your application's user interface (Android only)" on
page 41.
2. Note the value of the package property.
3. In UFT, create a test object to represent the application.
a. Open the Object Repository window. For instructions on working with the Object
Repository window, see the UFT documentation.
b. In the Object Repository window, select the relevant Device test object.
c. Create a new child test object (Object > Define New Test Object) and assign it
unique description properties.
i. In the Define New Test Object dialog box, define the following:
Class
App
Name
A unique name for the test object.
Best practice: Assign a descriptive name that
indicates the application's name or purpose.
Test object details
Description
properties
ii. Click
A. Remove all properties EXCEPT for identifier.
B. For identifier, enter the value you noted from
the uiAutomatorViewer package property.
to open the Add Properties dialog box.
iii. In the Add Properties dialog box, click
box.
to open the New Property dialog
iv. In the New Property dialog box, add a systemApp property with the value
True.
HP Mobile Center (1.01 Patch 2)
Page 47 of 61
UFT on Mobile Center Quick Start
How do I run tests on mobile applications using
UFT?
How do I run a test?
In UFT, click Run. UFT connects to HP Mobile Center and the remote access window
opens, enabling you to view the application's behavior as UFT runs the test steps.
Considerations
l
l
l
If the remote access window fails to load the user interface completely, UFT still
continues to run steps on the mobile device itself, but does not run any Insight steps.
This is because Insight interacts with the remote access window, and not the device.
If a test is designed to run on multiple applications during a single run session, make
sure that the test is configured to open the each application separately before
running the test. For details, see "How do I edit test steps?" on page 35
When running a test that contains steps on multiple devices, all remote access
windows open layered in the same location overlapping each other. The windows
remain in a stationary position for the duration of the run session. Running a step on
a "hidden" remote access window does not move the window to the foreground. This
can prevent steps, including Insight steps, from running correctly.
To solve this, add the following code to the test (or a function library):
'@Description Activate the remote access window for the device
Public Function Device_ActivateRemoteWindow(ByRef device)
raWindowHwnd = device.GetROProperty("hwnd")
Window("is child window:=False", "hwnd:=" &
raWindowHwnd).Activate
HP Mobile Center (1.01 Patch 2)
Page 48 of 61
UFT on Mobile Center Quick Start
End Function
RegisterUserFunc "Device", "ActivateRemoteWindow", "Device_
ActivateRemoteWindow"
What happens when a run session starts?
1. UFT connects to the specified HP Mobile Center server but does not perform any
action until it reaches a step on a mobile test object.
2. When the run reaches a step on a mobile test object, UFT determines the device
and application:
Device
Application
n
If the Device test object contains an ID description property,
UFT uses the identified device.
n
(Default) If the Device test object does not contain an
ID description property, UFT uses the device defined in
UFT's Record & Run Settings.
n
If the step contains an App test object, UFT use the
Identifier and Version properties to locate the application.
n
If the step does NOT contain an App test object (for
example, an Insight step or a device-level method), UFT
uses the application defined in UFT's Record & Run
Settings.
3. After UFT determines the device and application, UFT locks the device (so that only
UFT can perform actions on it) and performs the following flow:
HP Mobile Center (1.01 Patch 2)
Page 49 of 61
UFT on Mobile Center Quick Start
What happens when a run session ends?
l
l
l
All remote access windows that were opened for the run session close.
On every device, HP Mobile Center sends the application that it opened to the
background. If more than one application was opened on a device, only the first
application is sent to the background.)
If "Uninstall application after run" on page 16 is selected in the record and run
settings, HP Mobile Center uninstalls the application from the device (unless the run
HP Mobile Center (1.01 Patch 2)
Page 50 of 61
UFT on Mobile Center Quick Start
fails and the uninstall is configured to occur only "If the run passed" on page 16).
l
UFT's Run Results Viewer displays the following: Learn more about the Run Results
Viewer
The Run Results Viewer opens by default after a run session. You can modify this
behavior in UFT's Options dialog box. You can also open the Run Results Viewer
manually from UFT or from the Start menu (under HP Software). For more details on
the Run Results Viewer, see the UFT documentation.
Summary
General result details for the run session, including details on
the devices and applications.
Steps
Detailed run results, with success/failure status for each step.
Captured
Data pane
Screenshots of the device at various steps. (The test object is
not highlighted.)
(Displayed only if Tools > Options > GUI Testing > Screen
Capture > Save still image captures to results is set to
Always.)
Local
Displays the data to collect from the mobile device during a
System
run session, for example, details on the mobile device's CPU,
Monitor pane memory, and free memory.
(Displayed only if vitals were defined in the record and run
settings prior to the run session.)
Device Logs
node
The device log file name, stored locally on the UFT computer
in the run results folder. If multiple devices were used, child
nodes are displayed for each device with a path to the device
log that was collected during the run session.
StopNV step
A path to the Network Virtualization results file, stored on the
Network Virtualization server. This file contains traffic and
performance information and analysis.
(Displayed only if this step type is included in the run)
HP Mobile Center (1.01 Patch 2)
Page 51 of 61
UFT on Mobile Center Quick Start
How do I use network virtualization?
(Optional) Run virtualized networks for your mobile devices
During a run session, you can use virtualized networks for your mobile devices. This
enables you to test the mobile device's performance in a variety of different scenarios
with differing network performance.
1. In HP Network Virtualization for Mobile, create different profiles to simulate
varying network conditions. For details on creating and deploying network
virtualization profiles, see the HP Network Virtualization User Guide.
2. In HP Mobile Center, configure the details of the virtualized network. For details,
see the HP Mobile Center Help (http://mobilecenterhelp.saas.hp.com).
3. In your UFT test or component, insert a Device.StartNV <profile name>
statement to apply the network conditions defined in the network virtualization
profile.
4. At the end of the test, or earlier, if relevant, insert a Device.StopNV statement to
stop running the virtualized network.
At the end of a run session, the Run Results Viewer displays the path to the Network
Virtualization results file, which is stored on the Network Virtualization server. This file
contains traffic and performance information and analysis.
HP Mobile Center (1.01 Patch 2)
Page 52 of 61
UFT on Mobile Center Quick Start
Considerations and Limitations when testing
mobile applications
l
l
Use the Mobile Add-in in UFT to operate on native mobile objects, or on Web objects
inside mobile applications.
When working with Mobile objects, UFT uses all identification properties as part of
the description used to identify the object. In addition, the description includes some
complex properties comprised of JSON objects.
You cannot modify the descriptions that UFT creates when learning mobile objects.
l
l
l
Mobile devices on which you run a test remain locked by the HP Mobile Center until
the test or component is closed, even if the test or component is not currently
running.
On Android devices, the MobileView object is not recorded. To add a MobileView
object, create it manually in the object repository (using the Define New Test
Object), and do the following:
n
Set the isscrollable property to true.
n
Set the index property, if relevant.
n
Remove all other properties (do not leave blank, remove).
After defining the connection information for HP Mobile Center in the Options dialog
box, the remote access window opens every time a record or run session begins.
To prevent this window from opening when you are not testing mobile applications,
select Do not record and run tests on mobile in the Mobile pane of the Record and
Run settings dialog box.
l
When using the Mobile Add-in with ALM:
n
The Asset Comparison tool does not compare changes in the Record and Run
Settings for Mobile tests.
HP Mobile Center (1.01 Patch 2)
Page 53 of 61
UFT on Mobile Center Quick Start
n
l
l
Test object icons for Mobile objects are not displayed in the Test Plan module or
for object repositories saved in ALM.
The UFT Mobile Add-in supports only recording and running steps on mobile
applications. The following UFT abilities are not supported when working with mobile
objects: n
Object Spy
n
Navigate and Learn
n
Active Screen
n
Highlight Object in Application (from the object repository)
n
Add Test Object (from the object repository)
n
Programmatic descriptions
n
Smart identification
n
Ordinal identifiers
n
Visual Relations identifiers
n
Regular expressions for properties
n
Maintenance Run Mode
n
Update Run Mode - only the option for updating checkpoints and output values is
supported.
n
Local System Monitors. Instead, you can instruct UFT to collect Mobile vitals in
the Record and Run Settings dialog box. This data is then presented in the Local
System Monitor pane in the run results.
n
Low-level recording
Launching more than one application automatically in a single test or component run
session is not supported.
Workaround (for Android only):
Add the following steps to launch a second application during a run session:
HP Mobile Center (1.01 Patch 2)
Page 54 of 61
UFT on Mobile Center Quick Start
Device(“<device name>”).Home 'opens the device Home or Recent Apps
screen
Device(“<device name>”).InsightObject(“<application icon>”). Click
'clicks the icon (represented as an Insight object) for the
application
Note that the first step of this workaround opens the Home or Recent Apps screen of
the device and then clicks the icon of the second application (which is represented by
an Insight object).
l
On Android devices, the Swipe method is not recorded.
Workaround: Manually add a Swipe statement to the test or component.
l
l
For hybrid applications running on Android devices, only the text, isEnabled, and
isFocused properties are supported for checkpoints and output values. If you need to
check another property, use the GetROProperty method.
Using a component parameter to provide the value for a MobileCalendar object
argument values may lead to unexpected results. Workaround: Use a Data Table parameter for the MobileCalendar object argument
values.
l
When using UFT on a localized operating system that uses comma characters as a
decimal point, using the comma character for a decimal point is not supported.
Workaround: Use the period for a decimal point. You may need to manually fix
recorded steps to remove all commas used as decimal points.
Note: It is recommended to always use the period character as a decimal point,
regardless of the locale of your operating system.
HP Mobile Center (1.01 Patch 2)
Page 55 of 61
UFT on Mobile Center Quick Start
Examples of UFT Tests on Mobile Applications
This section provides some sample tests that you can use to get an idea of what a UFT
test running on Mobile applications might look like.
Select a radio button in a Mobile radio group
Device("Device").App("com.sample.UICatalog").MobileLabel
("ToggleButtonsAndRadioGroups").Tap
Device("Device").App("com.sample.UICatalog").MobileRadioGroup
("MobileRadioGroup").Select 1
Device("Device").App("com.sample.UICatalog").MobileToggle("ON").Set "on"
Device("Device").Back
Deselect an item in a Mobile list view
Device("Device").App("com.sample.UICatalog").MobileLabel("ListViewActivity").Tap
Device("Device").App("com.sample.UICatalog").MobileLabel("Doctrina4").MakeVisible
Device("Device").App("com.sample.UICatalog").MobileLabel("Doctrina4").Set "off"
Scroll the view (method added manually, not recorded)
Device("Device").App("com.sample.UICatalog").MobileView("View").ScrollOnePage
"forward"
Device("Device").Back
Select an item in a Mobile spinner
Device("Device").App("com.sample.UICatalog").MobileLabel("Spinners").Tap
Device("Device").App("com.sample.UICatalog").MobileDropDown("Torso").Tap
Device("Device").App("com.sample.UICatalog").MobileLabel("Doctrina3").MakeVisible
Device("Device").App("com.sample.UICatalog").MobileLabel("Doctrina3").Set "on"
HP Mobile Center (1.01 Patch 2)
Page 56 of 61
UFT on Mobile Center Quick Start
Device("Device").Back
Enter text in a Mobile edit box
Device("Device").App("com.sample.UICatalog").MobileLabel("TextAndButtons").Tap
Device("Device").App("com.sample.UICatalog").MobileButton("Button").Tap
Print "Text before: " & Device("Device").App("com.sample.UICatalog").MobileEdit
("MobileEdit").GetROProperty("text")
Device("Device").App("com.sample.UICatalog").MobileEdit("MobileEdit").SetFocus
Device("Device").App("com.sample.UICatalog").MobileEdit("MobileEdit").Set "aszx"
Device("Device").App("com.sample.UICatalog").MobileEdit("MobileEdit_2").SetFocus
Print "Text after: " & Device("Device").App("com.sample.UICatalog").MobileEdit
("MobileEdit").GetROProperty("text")
Device("Device").Back
If Not Device("Device").App("com.sample.UICatalog").MobileLabel("DateActivity").Exist
Then
Device("Device").Back
End If
Set the date in a Mobile calendar
Device("Device").App("com.sample.UICatalog").MobileLabel("DateActivity").Tap
Device("Device").App("com.sample.UICatalog").MobileCalendar("DateTime").Set
"November 28, 2014","MMM d, y"
Device("Device").App("com.sample.UICatalog").MobileCheckbox("CheckBox").Set "on"
Device("Device").Back
Touch a Mobile device at a specific point
Device("Device").Touch 111.849998,995.410034
HP Mobile Center (1.01 Patch 2)
Page 57 of 61
UFT on Mobile Center Quick Start
Make sure a Mobile button exists before tapping it
Device("Device").App("com.sample.UICatalog").MobileButton("Another
Button6").MakeVisible
print "Exist true: " & Device("Device").App("com.sample.UICatalog").MobileButton
("Another Button6").Exist
print "Exist false: " & Device("Device").App("com.sample.UICatalog").MobileLabel
("DateActivity").Exist(10)
Device("Device").App("com.sample.UICatalog").MobileButton("Another Button6").Tap
Perform operations at the Mobile device level and use Insight on a Mobile
control
Device("Device").Back
Device("Device").Home
Device("Device").RecentApps
Device("Device").InsightObject(
).Click
Device("Device").SetOrientation "landscape"
Tap a Hybrid object: a WebElement inside a Mobile application
Device("Device").App("com.example.hubrid").MobileWebView
("MobileWebView").MobileWebElement("A").Tap
Check the results of the operations after they run (similar to checkpoints)
Dim ConfirmationExists, DirectFlight, FlightPrice
Device("Device").App("com.flight.mobile").MobileButton("Reserve").Tap
' check confirmation
ConfirmationExists = Device("Device").App("com.flight.mobile").MobileObject
("Confirm").Exist(10)
If ConfirmationExists Then
HP Mobile Center (1.01 Patch 2)
Page 58 of 61
UFT on Mobile Center Quick Start
' verify that the flight is direct
DirectFlight = Device("Device").App("com.flight.mobile").MobileCheckbox
("Direct").GetROProperty("isChecked")
If DirectFlight Then
' verify price
FlightPrice = Device("Device").App("com.flight.mobile").MobileCheckbox
("Direct").MobileLabel("Price").GetROProperty("text")
If FlightPrice = Param_ExpectedPrice Then
Reporter.ReportEvent micPass, "Reserve Flight", "Direct flight reserved. Price: "
& FlightPrice
Else
Reporter.ReportEvent micFail, "Reserve Flight", "Unexpected price: " &
FlightPrice
End If
Else
Reporter.ReportEvent micFail, "Reserve Flight", "Flight not direct!"
End If
Else
Reporter.ReportEvent micFail, "Reserve Flight", "Flight not confirmed"
End If
See also: "Mobile Add-in Object Model Reference" on page 1 of the HP Mobile Center
online Help (http://mobilecenterhelp.saas.hp.com)
HP Mobile Center (1.01 Patch 2)
Page 59 of 61
Send Us Feedback
Can we make this UFT on Mobile Center Quick Start better?
Tell us how: SW-Doc@hp.com
HP Mobile Center (1.01 Patch 2)
Page 60 of 61