Skip to content

Build Test Scripts for Android App using Appium Inspector

In this article you will learn how to build a test script for HICC Production Android app using Appium Inspector in Worksoft SaaS. For this exercise, let us take the first test case from the Test Case Repository (Test Case Repository for Mobile App Testing is not yet published hence the link will redirect to Mobile App article home page) for Health Insurance Cost Calculator(HICC) Native Mobile App.

Let us create the test script by following the steps in the below order.

1. Launch the HICC Production Android Mobile App in Appium Inspector.

2. Login to the Worksoft SaaS Domain and select the required project from the dropdown.

3. Click on the Hamburger icon and click on the Test Scripts.

4. Click on Create button.

5. Select the required Product from the 'Product Name' dropdown and click on Continue button (If you wish to use the same script for Production iOS app also, select the product for which both the Android and iOS binaries are uploaded).

6. Enter the Test Script name as 'Enter Inputs and Verify Calculated Premium and Penalty’.

7. Switch to the Appium Inspector where the app is launched.

8. Once the HICC Production Android app is launched, let us verify an element on the home screen of the app to ensure that the app is launched as expected. (Please note that, similar to Appium Inspector, you do not need to select the HICC app from the list of apps in the mobile device in cloud executions i.e. the app is launched automatically in the device selected to execute the test on cloud).

9. Select the Health Insurance Cost Calculator text using 'Select Elements' tool. Once you have selected the header text, look for id or resource-id attribute in the Selected Element section as shown in the below screenshot.


There are two ways of using the resource-id attribute value. You can either use the entire value com.eureqa.eureqaprod:id/pageHeaderText or use only the value available after the text id/ from the entire value pageHeaderText.

As you can notice in the above locator, if you use the entire value of resource-id attribute, it will not work for the other environments of HICC apps as the locator contains the environment name prod. In this case let us go with the 2nd approach and use only the text after the id/ from the entire value which will work for all environments.

You can use assertText command in order to verify the Header text and construct the locator in the Target field as id=pageHeaderText, provide the header text in the Value field and save the instruction as shown in the below screenshot.


10. The next step in the Test Case is to enter the Age. Select the Age input field using the 'Select Elements' tool.

Once you have selected the Age input, you will see the resource-id attribute in the Selected Element section as shown in the below screenshot. 


You can use type command in order to enter the value in a input field and follow the step 9.


11.Similar to the Age field, enter the values for the Income and Zipcode field by following the same approach. 


12. After entering the values in the input fields the next step is to click on the 'Calculate' button. You can use tap command to click on the calculate button.

In the above steps you have used resource-id attribute to write an id locator. In this step let us try to construct a locator using xpath also and learn how to use multiple locators for the same element in Worksoft SaaS. 

Upon selecting the Calculate button, you can write the id locator using resource-id attribute and update it in the Test Script in Worksft SaaS.


For constructing the xpath locator look for text/label/value/name attributes in the 'Selected Elements' section. As you can see the text attribute is defined for the Calculate button, write the xpath as //android.widget.Button[@text="Calculate"] and add it as the second locator in the Target field. Prioritize the second locator as shown in the below screenshot.


13. The final step is to verify the Premium and Penalty along with the Result Header.



You can use assertText command to verify all three elementsA complete script to verify the Premium and Penalty would look like this:  



Feedback and Knowledge Base