Adding a Swipe Until Action to a Test Case
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. If you’re testing on an iOS app, 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 (for iOS apps), resulting in a failed test.
Adding a Swipe Until Action to a Test Case Step
- Log in to your Sofy account.
- Select Automation from the left navigation bar.
- Search for and select a test containing Swipe actions.
- If you have multiple steps that contain a Swipe action, click on the first step and select Edit from the toolbar that pops up.
- Navigate to the Swipe Until tab.
- Toggle on the Swipe Until setting to enable it.
- 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: Only for iOS apps. 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.
- Select Save Step Changes. The Swipe step will change to a Swipe Until step.
- If you have multiple Swipe steps, disable or delete the remaining Swipe steps in the test case.
- 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!