测试 Android 系统应用程序

在创建要在 Android 系统应用程序上运行的 UFT One 测试之前,必须检索相关的 Android 属性值并将其映射到 UFT One 或者 Digital Lab 属性。

然后,将这些属性用作 UFT One 测试步骤中的参数值。

检索并映射 Android 属性值

使用 uiAutomatorViewer 工具检索所需的属性值。

要使用 Android 属性值,请执行以下操作:

  1. 访问 uiAutomatorViewer 工具。有关详细信息,请参阅分析应用程序的用户界面
  2. 检索以下属性的值:

    package

    视图中当前显示的应用程序的标识符。

    映射到 App 测试对象的 identifier 属性。

    content-desc

    对象的 accessibilityid 属性。

    class

    映射到测试对象的 class 属性。

  3. UFT One 中打开测试,并录制任何应用程序上的步骤。例如:

    Device("Device").App("UICatalog").MobileList("List").Select 0
  4. 根据以下示例,手动调整步骤的各个部分。

    Device("micclass:=Device").App("Identifier:=com.sec.android.app.launcher", "systemApp:=True”).MobileView("class:=Label", "accessibilityId:=Applications").Tap

    设备

    使用以下某种方式:

    Device("DeviceName"),如果在对象存储库中定义了设备测试对象

    Device("micclass:=Device"),如果要使用编程描述

    Identifier

    定义应用程序的标识符。

    此值映射到 uiAutomatorViewer 中的 package 属性。

    systemApp 设置 systemApp:=True
    class

    定义测试对象的 class 属性。

    accessibilityId 设置 "accessibilityId:=Applications"

通过创建其他测试步骤并运行测试来继续。

有关详细信息,请参见录制移动测试编辑移动测试运行移动测试

返回页首

Android 系统应用程序测试示例

以下步骤显示了如何访问计算器系统应用程序,添加数字,计算结果,然后清除显示:

' Navigate to the Home page on the device
Device("micclass:=Device").Home
' Navigate to the list of apps on the device
Device("micclass:=Device").App("Identifier:=com.sec.android.app.launcher", "systemApp:=True”).MobileView("class:=Label", "accessibilityId:=Applications").Tap
' Swipe to navigate to the calculator app
While Not Device("micclass:=Device").App("Identifier:=com.sec.android.app.launcher", "systemApp:=True").MobileView("class:=Label", "accessibilityId:=Calculator").Exist(5)
    Device("micclass:=Device").Swipe "left"
Wend

' Open the calculator app
Device("micclass:=Device").App("Identifier:=com.sec.android.app.launcher", "systemApp:=True").MobileView("class:=Label", "accessibilityId:=Calculator").Tap
' Press 1 on the calculator
Device("micclass:=Device").App("Identifier:=com.sec.android.app.popupcalculator", "systemApp:=True").MobileView("class:=ImageButton", "accessibilityId:=1").Tap
' Press + on the calculator
Device("micclass:=Device").App("Identifier:=com.sec.android.app.popupcalculator", "systemApp:=True").MobileView("class:=ImageButton", "accessibilityId:=Addition").Tap
' Press 5 on the calculator
Device("micclass:=Device").App("Identifier:=com.sec.android.app.popupcalculator", "systemApp:=True").MobileView("class:=ImageButton", "accessibilityId:=5").Tap
' Press = on the calculator
Device("micclass:=Device").App("Identifier:=com.sec.android.app.popupcalculator", "systemApp:=True").MobileView("class:=ImageButton", "accessibilityId:=Equal").Tap
' Press C (Clear) on the calculator
Device("micclass:=Device").App("Identifier:=com.sec.android.app.popupcalculator", "systemApp:=True").MobileView("class:=ImageButton", "accessibilityId:=Clear").Tap

返回页首

另请参见: