All Products
Search
Document Center

Mobile Testing:Record a script

Last Updated:Jul 13, 2023

You can use the online recording feature to install apps on remote devices, record steps, and generate test scripts from a web-based interface.

Prerequisites

A test case library is created and associated with a specified app. For more information, see Create a test case library.

Install an app

  1. Log on to the Mobile Testing console.

  2. In the left-side navigation pane, choose Testing Management > Test Case. The Scripts tab appears.

  3. Select a test case library and a test case library version from the Case Library drop-down list.

    image..png
  4. Click Online Recording. The Online Recording panel appears.

    录制脚本1705
  5. In the Online Recording panel, perform the following operations:

    1. Select Sharing Device.

    2. Specify Brand, System Version, and Resolution to filter recording devices.

    3. Select a recording device from the device list.

    4. Click OK. The Select App dialog box appears.

      Note

      Devices in the In Use state cannot be selected.

      image.png
  6. In the Select App dialog box, select or upload an app.

    • Select an app. Select the app that you want to install and click Install in the Operation column to install the app on the recording device.

      image.png
    • Upload an app. Click Upload Test App to upload an app. For more information about how to upload an app, see Upload an app.

  7. After the app is installed, the system automatically goes to the Online Recording page. The online recording usage duration is displayed in the upper-left corner of the page. The usage duration starts from when you enter the remote debugging page.

    Note

    In the left-side remote device pane, view the values of the Remaining Free Trial Period and Remaining Resource Plan Period parameters.

    On the left side of the online recording page, the remote device on which the app is installed is displayed. For more information, see Remote device description.

    截屏2021-02-19 下午2

    To exit the online recording, click Exit.

Create a script

1. On the Online Recording page, perform one of the following operations based on your business requirements:

  • Click Create Script. In the Create Script panel, configure the parameters to create a script. The recorded steps are saved to the new script.

  • Click Select Existing Script. In the Select Script panel, select an existing script. The recorded steps are saved to the specified script to overwrite the original steps.

    选择脚本右侧栏1415
    Note

    You must configure the script that you want to select in advance. For more information, see Create a script.

截屏2021-02-19 下午2
Note

In this example, Create Script is used.

2. In the Create Script panel, configure the parameters.

新建脚本右侧栏1420

The following table describes the parameters that are used to create a script.

Parameter

Description

Test Case Library Version

The version number of the test case library.

Note

You must create a test case library version in advance. For more information, see Create a test case library version.

Script Name

The name of the script.

The name must be a string.

The name must be 2 to 50 characters in length.

The name can contain letters, digits, underscores (_), and hyphens (-).

New Directory

The storage path of the script.

Note
  • You must create a script directory in advance. For more information, see Create a script directory.

  • If no directory is created, the script is saved to the root directory.

  • You can enter a keyword in the search box to search for an existing script directory. Fuzzy match is supported.

Script Description

The description of the script. The description facilitates subsequent query and review.

3. Click OK. The editor for the created script appears on the right side of the Online Recording page.

For more information, see Script editor description.

Record steps

1. On the Online Recording page, click Record and select Record by Control or Record by Coordinate to record the script.

Note

The following recording methods are supported: Record by Control and Record by Coordinate. We recommend that you select Record by Control.

2. On the remote device, click the app to simulate taps on the screen. Then, the steps are recorded and generated on the Script Steps tab.

Note
  • A long period of time is required to start an app or load a page, and steps can be recorded only after page controls are fully loaded. If an app startup or a page redirect is involved in the recording, we recommend that you add the Wait step.

3. (Optional) In the script editing toolbar, click Input to configure input parameters for interaction scenarios.

4. (Optional) To improve the replay success rate, we recommend that you use the Xpath code on the Page Source tab to correct your script steps.

5. Click Stop to terminate the recording.

6. Click Replay to verify the steps.

The following items describe the possible colors of the dot before a step:

  • Green: The replay is successful.

  • Red: The replay failed.

  • Yellow: The step is not replayed.

7. Click Save or Save As to save the script.

8. Click Exit to exit the online recording.

录制1

After you exit the online recording, the Scripts tab appears. The recorded script is displayed in the script list. You can click the script name to view the script content.

显示新建脚本1505

Replay steps

  • Replay all steps. After the script is recorded, click Replay to replay all the recorded steps.

  • Replay a single step. In each recording step, click Play Single Step to replay the current step.

  • If you need to correct a recording step, you can click Insert Step in Next Row, Edit, or Remove Step corresponding to the step.

Remote device description

A remote device is used to show the basic operations that can be performed on a device.

截屏2021-02-19 下午2

No.

UI element

Control

Description

1

System settings toolbar

Terminal type

The brand and model of the remote device.

Usage duration

  • The used duration of the free quota or resource plan.

  • The remaining duration of the free quota or resource plan.

High/Standard

Switches between high definition and standard definition.

Coordinates

Shows coordinates after you turn on Coordinates and move the pointer over the app page.

2

Touch screen operations toolbar

Input

Opens a dialog box where you can enter content in fields. For example, you can enter a username or a password.

Clear input

Clears the content that you specified in fields.

Restart an application

Restarts an app without clearing the cache.

Restart (Cache clearing)

Restarts an app and clears the cache.

Swipe Up, Swipe Down, Swipe Left, or Swipe Right

Swipes the screen up, down, left, or right.

3

System icons

-

Simulates three system icons of an Android mobile phone.

Note

Drag the 十字符 icon to move the system settings toolbar.

Script editor description

截屏2021-02-19 下午3

1: Status bar

Item

Description

Usage duration

Shows the usage duration of the online recording feature. The system starts to count the usage duration when you go to the Online Recording page.

Help icon

Provides the Remaining Free Trial Period and Remaining Resource Plan Period values of the test device within the current account. The values are displayed when you move the pointer over the Help icon.

2: Save and exit

Button

Description

Save

Saves the current script.

Save As

Saves an existing script as a new script.

Exit

Exits the recording page.

3: Script name

Control

Description

Script name drop-down list

Shows the name of the current script.

You can click the script name and select Create Script or Select Another Script from the drop-down list to use another script.

4: Toolbar

Icon

Description

Record or Stop

Starts or stops recording steps.

Replay

Replays all steps after the recording is complete.

Refresh Page

Refreshes all controls if the system does not identify all controls in a short period of time.

Logs

Shows logs of the Appium client and Appium server.

Clear Steps

Clears the steps that are recorded.

Reset Step

Restores a step to the initial state before you start recording.

5: Tabs

Tab

Description

Script Steps

Shows the steps that are recorded.

Parameter Settings

Allows you to configure input parameters for interaction scenarios.

Page Source

Provides the Xpath code that you can use to correct script steps to improve the replay success rate.

6: Interval selection switch

Item

Description

On

After you turn on the switch, you can press the Shift key to select multiple steps at a time.

Off

After you turn off the switch, you cannot press the Shift key to select multiple steps at a time.

7: Step editing icons

Icon

Description

Play Single Step

Plays the current step.

Insert Step in Next Row

Inserts a step after the current step.

Edit

Edits the current step.

Remove Step

Removes the current step.

Note

When you move the pointer over a step, the sequence number of the step is changed to the Move icon. You can drag the Move icon to change the sequence of the step.

8: Script editing toolbar

The following table describes the categories that are provided in the script editing toolbar.

Category

Description

Common

Simulates the basic operations that can be performed on devices.

Image

Recognizes image controls by using different methods.

Note
  • To improve the accuracy of image recognition, we recommend that you perform the following operations:

    • Select areas that contain contrasting colors when you take screenshots.

    • Select clear characters when an optical character recognition (OCR) tool is used.

  • If the system fails to recognize an image, we recommend that you use custom steps or contact Alibaba Cloud technical support. For more information, see Technical support.

Custom

Adds custom code blocks, steps, or scripts.

Assertion

Determines whether a control exists or whether the text meets your expectations.

Conditional statement

Configures conditional branches in a step.

Loop statement

Configures loop branches in a step.

Application operation

Restarts or installs an app in a step.

What to do next

Create a test case