Skip to main content
Version: 7.2.0

Integrating Test Automation on Smartface

As applications grow, it will be harder for everyone to keep track of side effects or ensure that business requirements are met. Therefore, test automation exists to ensure that nothing breaks on your application while you develop new features.

This document is focused on Test Engineers who want to automate testing process using tools like Appium. If you are a developer, please refer to the guide below on how to implement necessary fields for your application:

Test Automation

This Document will focus on Test Automation tool called Appium. The baseline steps and configurations are mostly similar between other Test Automation Tools.

Launching the Application on Test Automation Environment

When Smartface Application is built, Smartface Application is no different than any other mobile application. There are no extra steps necessary to fire up Test Automation Tool specific for Smartface.

Install and configure process of Appium is out of scope of this document and will not be covered in this document. Please follow the official guide provided by Appium.

This is how a Smartface Application looks like on Appium:

iOSe

Android

Writing Test Automation Scripts

Coding test automation scripts are outside of this scope and specific to Appium or other test automation tools that you use. For more information, please follow the official guide provided by Appium.

Selectors to be Used for Test Automation Scripting

There are 4 main fields that can be used to distinguish elements between each other. Your testing scripts should revolve around one main field and you should use others on special occasions.

To learn more about selectors, please refer to this Appium Guide.

id

This is resource-id for Android and name for iOS. The developer of the application should assign those fields for you.

Using this selector for scripts is recommended by both Appium and Smartface. It will yield to healthiest result.

When it is not enough to use ID

When there is Recycling field like ListViewItem or GridViewItem

  • RecyclerView for Android
  • TableView for iOS

ID selector will not be able to distinguish elements inside of this view since they are designed to be repeatable and potentially infinite.

On Android, when you get this kind of item by ID, you are going to get multiple results.

Text

This is the human readable text content visible to the users. This selector can be used on specific elements if you are certain that it will be unique.

The purpose of this selector is to ensure if certain text is written in the application. Using this to distinguish between elements might work but not recommended. Only use within specific needs.

XPath

This selector is assigned by the operating system itself and it provides where the specific element belongs.

This selector may change over time and not a reliable way to revolve your script based on. Appium also reported performance issues when searching elements based on xpath.

When is it O.K. to use XPath

When a native dialog like Alert or Permission was prompted, XPath will have a standard pattern and it can be used to click the elements inside of them. Your developer might not be able to assign proper ID to them since those components are handled by the operating system itself.

Accessibility ID

This is accessibility-id for iOS and content-desc for Android.

The purpose of this selector is normally to provide better text-to-speech experience with TalkBack or VoiceOver features for impaired users. When this feature is provided, this selector will have a human readable text over them.

info

If you decide to use this as selector, keep in mind that accessibility features will be severely limited.

More info can be found about accessibility in general in this document:

Accessibility

What if I have Accessibility Support

If you also have accessibility support, this selector will have a different use case and you should be wary when using this selector on your scripts.

What if I don't have Accessibility Support

If your application is not going to use text-to-speech in the future, you can also use this selector to distinguish different elements.

Tips & Tricks for Writing Test Automation Scripts

Not all applications are straightforward and some might have caveats, some might require additional coding.

Searching for ListView or GridView Items

As stated above, ID of items in ListView or GridView will not yield all of the items inside. When you are searching this view with its ID, the tool will only return currently shown items on current state. As stated above, this view may contain more items than it is shown since they can be reached by scrolling.

The ID of the items for ListView or GridView will be same for each element. If you search by element like this:

Following result will yield:

As stated above, the yielding result only contains the elements that are visible in the current state.

Scroll Through ListView or GridView elements

To get a gist of scrolling programmatically with your script, refer to this tutorial by appium.

Since we need to be sure about how many elements or pixels to scroll. You, as a Test Engineer should decide on which method would be best for your use case.

Example Use Case

  1. Search with the selector of your desire of ListViewItem using this method.
    1. This will return an array of elements of visible elements.
  2. Define a variable as counter, start at 0.
  3. Define another variable as current height.
  4. You can get the size of a single element using this method.
  5. Increase the counter by element count (5 in the above example) and height count by total height.
  6. Scroll that pixel below using this method.
  7. Search again and repeat the process until you reach the end.

You can also refer to this document to come up with a different approach.