Swipe Until Overview

Updated by Kashif Hussain

What is Swipe Until?

When testing a mobile app, you may need to swipe on the screen to locate and select an element. However, the number of swipes required often varies across devices due to different screen sizes and layouts. This can cause automated tests to fail when the target element requires more or fewer swipes than expected.

The Swipe Until condition solves this problem by automatically scrolling until a specific UI element or text becomes visible. It is especially useful in dynamic, scrollable views such as dropdowns, spinners, or long lists where items are not immediately visible on screen.

During execution, the system will continue swiping until:

✅ The target element is found → test proceeds

❌ The maximum number of swipes is reached → test fails

You can utilize this Swipe Until feature in two ways:

With the growing updates to the feature, Sofy now provides smarter execution options between XML and OCR approaches.

Scenario 

Recommended Mode 

Reason 

Structured date/month picker 

XML 

Elements are grouped and predictable 

Country or city list 

OCR 

Items are dynamic and ungrouped 

Element already visible 

XML or Select 

OCR adds unnecessary overhead 

Dynamic dropdown with partial rendering 

OCR 

Prevents false positives from hidden XML elements 

Using Session and Template Variables 

Sofy supports using variables in Swipe Until actions for dynamic scenarios: 

  • Session Variables: Useful when the value for swipe until is set during the test flow. 
  • Template Variables: Ideal for reusable test steps shared across multiple test cases. 

You can create a reusable Swipe Until template and override its variable per test case.  This avoids recording the same Swipe Until step repeatedly for similar screens — you simply update the variable value to match the new target text or component. 

Example:  Create a “Swipe Until Item” template → in each test case, override the variable with "USA", "France", or "Germany" as needed. 

 

Handling Complex UI Layouts 

In some applications, certain screens have multiple sections or dynamic subheadings under the same title.  If a single Swipe Until OCR/XML action is used for such screens, the scroll might stop before the target area fully stabilizes, leaving some interactive elements out of view. 

Recommended approach: 

  1. Add a Swipe Until action for a static component or heading that appears just below your target area. 
  2. Then, add another Swipe Until OCR/XML action for the element you want to interact with at start which will swipe upward.  

This ensures the view settles properly, and all related elements in the middle of the screen are visible and can be interacted with reliably. 

 

When should you use XML over OCR 

  1. If the target element is already visible. 
  2. For grouped or repeating lists (like month-day-year pickers), OCR can misread elements that repeat in the visible region (e.g., December appearing before January), leading to unstable selection. 

 

Summary 

Scenario 

Recommended Swipe Until Mode 

Structured or grouped lists (Months, Dates) 

XML 

Dynamic, unstructured lists (Countries, Cities) 

OCR 

Need to detect visible text only 

OCR 

Need to reuse scroll logic across tests 

Use Template + Variable Override 

Element already visible 

Direct action, no OCR needed 

By applying the recommended modes and best practices outlined above, you can ensure that Swipe Until executes reliably across a wide range of device sizes, layouts, and app behaviors. This leads to more stable automation, fewer flaky failures, and smoother end-to-end test execution.


How did we do?