Adding a Swipe Until Action to a Test Case

Updated by Aishwarya Rai

During app testing, if you need to swipe on a mobile screen to find and select an element, you’ve probably noticed that the number of swipes required changes depending on the device and screen size you’re using. This makes performing the same automated test on multiple different devices difficult, as the test will likely fail on any device where more or less swipes are required to find and select the element you specified.

However, you can solve this problem using the Swipe Until condition. With this condition, you can specify that you’d like the system to swipe up or down on a selected page until it finds the specified element. You must also specify the maximum number of swipes you’d like the system to make before the test fails.

When a test is executed, the system will now swipe through the app until the specified element is found, resulting in a successful execution, or the maximum number of swipes is met, resulting in a failed test.

If you’re using the "Swipe Until" feature within a WebView and notice that it’s not functioning as expected, we suggest using standard swipe actions for these scenarios.

Adding a Swipe Until Action to a Test Case Step

  1. Log in to your Sofy account.
  2. Select Automation from the left navigation bar.
  3. Search for and select a test containing Swipe actions.
  4. If you have multiple steps that contain a Swipe action, click on the first step and select Edit from the toolbar that pops up.
  5. Navigate to the Swipe Until tab.
  6. Toggle on the Swipe Until setting to enable it.
  7. Under Which element(s) do you want to detect?, check the box next to each of the following settings to configure them:
    • Maximum number of swipes before step failure: Enter the maximum number of times you’d like the system to swipe through the app to find the specified element. If the system reaches the max number of swipes before finding the specified element, the test will fail.
    • Content Description: Check the box and provide a textual description of a user interface (UI) element you’d like the system to find and select. For example: ImageView or ImageButton.
    • Resource ID: Check the box and provide a resource ID of the element you’d like the system to find and select.
    • Text: Check the box and provide the text you’d the system to find and select.
    • Clickable: Check the box and indicate if the element is clickable.
    • Checked: Check the box and indicate if the element is a checkbox.
    • Enabled: Check the box and indicate if the element is an enable or disable setting.
    • Password: Check the box and indicate if the element is a password setting.
  8. Select Save Step Changes. The Swipe step will change to a Swipe Until step.
  9. If you have multiple Swipe steps, disable or delete the remaining Swipe steps in the test case.
  10. Once you’re done making changes to the test case, select Save Test in the top right-hand corner.

Example: Swipe Until Country Name is Found

Let’s say you’re testing the signup function of your app, and you have a step that requires the user to scroll through and select a country from a list. On one device, it may take five swipes to select the desired country, while on another device with a larger screen it may take only three swipes.

Instead of creating a separate test case for each device and screen size, you can enable the Swipe Until action to the first Swipe step and configure the following settings:

  • Text: Check this box, select Text from the dropdown, and enter the name of the country you want the system to find and select.
  • Clickable: Check this option to indicate that the element you want to find is clickable. Then select True from the dropdown.

Don’t forget to disable the remaining Swipe steps in the test case!


How did we do?