Custom scrolling for screen fragments
Scroll to elements inside fragments using custom swipe logic when scrollUntilVisible fails on partial screens.
The workflow
1. Reusable scroll Flow
# scroll_fragment.yaml
# Custom scrolling for targeted screen areas
# Required Env: TARGET_ID (The resource id of the element to find)
# Step 1: Initialize the state
# Use a flag to track if we've found our target yet
- evalScript: ${output.foundElement = 0}
# Step 2: Immediate check
# Before we start moving, let's see if the element is already there
- runFlow:
when:
visible:
id: "${TARGET_ID}"
commands:
- evalScript: ${output.foundElement = 1}
# Step 3: The targeted loop
# We continue swiping in the bottom region until foundElement becomes 1
- repeat:
while:
true: ${output.foundElement == 0}
commands:
# We swipe from 90% down the screen to 75% down the screen.
# This keeps the interaction strictly within the bottom fragment.
- swipe:
start: 50%, 90%
end: 50%, 75%
# Check again after the movement
# If the element is visible, we stop the loop
- runFlow:
when:
visible:
id: "${TARGET_ID}"
commands:
- evalScript: ${output.foundElement = 1}2. Implementation
Related content
Last updated
