All Products
Search
Document Center

Mobile Testing:Record a script

Last Updated:Mar 23, 2022

You can use the online recording feature to install apps on remote devices, record steps, and generate test scripts on web pages.

Prerequisites

  • Optional. A use case library version is created for the specified app. If no use case library version is created, the default version is used. For more information, see Create a use case library version.

  • Optional. A script directory is created. If no script directory is created, scripts are saved to the root directory. For more information, see Create a script directory.

  • Optional. A script of the Recording Type is created or imported. For more information, see Create or import a script.

  • The Use Cases page of the specified app is displayed. For more information, see Go to the Use Cases page.

Install an app

  1. On the Use Cases page of the specified app, click the Scripts tab.

  2. On the Scripts tab, perform the following steps:

    • Select a use case library version from the version drop-down list, or use the default version.

      Note

      You must configure a use case library version in advance. For more information, see Create a use case library version.

    • Click Online Recording. The Online Recording panel appears.

      Record a script
  3. In the Online Recording panel, perform the following steps:

    1. Configure the Brand, System Version, and Resolution parameters to filter recording devices.

    2. Select a recording device from the device list.

    3. Click OK. The app installation dialog box appears.

      Note

      Devices in the In Use state are dimmed and cannot be selected.

      Online Recording

  4. In the app installation dialog box, perform one of the following operations based on your business requirements:

    • Click Install to install the app on the specified recording device.

    • Click Select Another App. In the Select App dialog box, select an app to install the app on the specified recording device.

      Installation dialog box

      Note

      In this example, click Install.

  5. After the app is installed, the Online Recording page appears, and the system starts to count the duration of using the online recording feature.

    Note

    In the left-side window, 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.

    Screenshot

    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.

    Select Script panel
    Note

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

Screenshot
Note

In this example, click Create Script.

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

Create Script panel

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

Parameter

Description

Use Case Library Version

The version number of the use case library.

Note

You must create a use case library version in advance. For more information, see Create a use 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 (-).

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 by default.

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

Script Description

The description of the script. This information can help you query and review the script in subsequent operations.

3. Click OK. The editor for the new 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 Start Recording 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 clicks 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 playback success rate, we recommend that you use the Xpath code on the Control Tree tab to correct your script case.

5. Click Stop Recording to terminate the recording.

6. Click Play Back All to verify the steps.

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

  • Green: The playback is successful.

  • Red: The playback has failed.

  • Yellow: The step is not played back.

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

8. Click Exit to exit the online recording.

Record steps

After you exit the online recording, the Scripts tab appears. The recorded script is displayed in the left-side list and the content of the script is displayed on the right side of the page.

Display the created script

Remote device description

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

Screenshot

No.

Icon

Control

Description

1

System settings toolbar

Terminal type

The brand and model of the remote device.

Duration

  • The duration that you have used within your free quota or within your resource plan.

  • The remaining duration of your free quota or your 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 top of 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 App

Restarts an app without clearing the cache.

Restart App (Clear Cache)

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 Cross icon icon to move the system settings toolbar.

Script editor description

Screenshot

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 Mobile Testing service that belongs to your account. The values are displayed when you move the pointer over the Help icon.

2: Save or 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

Start Recording or Stop Recording

Starts or stops recording steps.

Play Back All

Plays back all steps after the recording is complete.

Refresh Control

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

Logs

Shows client logs and server logs.

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.

Control Tree

Provides the Xpath code that you can use to correct script cases to improve the playback success rate.

6: Interval selection switch

Item

Description

On

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

Off

After you turn off the switch, you cannot press Shift 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.

What to do next

Create a use case