Image-based test automation for mobile applications

With the Mobile Engine 3.0, you can steer screen objects in mobile applications by using image-based test automation.

Follow the instructions in this chapter to:

Image-based test automation for Mobile Engine 3.0 depends on screen resolution. If you create an image-based Module on a specific mobile screen resolution, it might not work when you execute tests on another device with different screen resolution.

Create image-based Modules

To automate mobile controls with image-based test automation, follow the steps below:

  1. In Tosca Commander, right-click on a Module folder and select Create->Create Mobile image based control.

Create Mobile image based control in the context menu of a Module folder

  1. In the Connect To Device window, enter the necessary information for the device and application as described in the table below.

Option

Description

Type

Select Android if you want to connect to an Android device or emulator.

Select iOS if you want to connect to an iOS device or simulator.

Configuration

Apply a custom configuration as described in chapter "Set Desired Capabilities for a scan".

Name

Enter the device ID of your mobile device.

You can also enter Auto in the following situations:

  • You connect only one Android device to your computer.

  • You connect multiple Android devices to your computer, and it is not important on which the scan is triggered.

  • You connect only one iOS or Android device to your Mac.

  • You connect multiple iOS or Android devices to your Mac, and it is not important on which the scan is triggered.

Appium Server

Enter the address of the Appium server.

To get the Appium server address, start the server manually. The Appium server address consists of:

  • The IP address of the computer on which the Appium server is running.

  • The default Appium port: 4723.

  • The standard path for the Appium server: /wd/hub.

Example: http://192.168.43.142:4723/wd/hub

To verify if the Appium server address is correct, open it in your browser.

You can also add a locally connected Android device or emulator. To do so, enter Local.

Radio button: Mobile App

Select to add a native or hybrid application.

Radio button: Web App

Select to add a mobile web application.

Path

Enter details about your mobile application, depending on the mobile operating system you use.

Configuration for a native application on a locally connected Android device

  1. Click Connect.

    Tricentis Tosca automatically opens Live View with a preview of the device and application. By default,Live View is in the Live mode, which means that you can use Live View interactions to navigate the mobile application.

  2. Interact with the Live View window to go to the screen that contains the control you want to scan.

  3. Click the Scan button to start creating image-based controls.

Scan button in the Live mode

When you select the controls, you can no longer interact with the mobile device using Live View. If you want to enable interactions, click the Live button.

  1. To select the control, drag the cursor over it in Live View.

    The Add Control window opens.

Live View and the Add Control window in the Scan mode

  1. In the Add Control window, enter the information for the control you selected.

Option

Description

Control Type

Select Button for a Button control.

Select Textbox for a Textbox control.

Select Generic for other controls.

Control Name

Specify the name for the control.

If the name already exists, Tricentis Tosca adds a number to the control name. If you don't select a name, Tricentis Tosca assigns the default name Control.

Accuracy

Move the slider to adjust the value for Accuracy. The higher the accuracy, the more the area of the control has to match the image-based Module.

The default value is 85%.

  1. Optionally, you can select additional identifying images to improve the stability of the image-based recognition.

  2. To proceed, click one of the following buttons:

    • Cancel to close the Add Control window without saving the Module. You can select another area on the screen or close the Live View window.

    • Scan Next to save the control and select other controls in the Live View window.

    • Finish to save the Module and close the Add Control and Live View windows.

  3. Create a TestStep out of the Module.

The Mobile Engine 3.0 does not support the Edit images function.

Create additional identifying images

You can identify image-based controls with additional images as reference points. This allows you to scan and steer the controls more precisely. To do so, follow the steps below:

  1. Scan a control as described in chapter "Create image-based Modules".

  2. In Live View, drag the cursor over an image that you want to use as a reference point.

    The reference image appears in the Additional Identifiers section of the Add Control window. You can now adjust its Accuracy by moving the slider next to it.

Additional Identifiers in the Add Control window

  1. To scan additional reference images, drag the cursor over another image in Live View.

    If you want to delete reference images, click on the icon.

  2. After you have added all reference images for your image-based Module, you can select:

    • Cancel to close the Add Control window without saving the Module. You can select another area on the screen or close the Live View window.

    • Scan Next to save the control and select other controls in the Live View window.

    • Finish to save the Module and close the Add Control and Live View windows.