Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions advanced/recipes/scrolluntilvisible-for-fragments.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,43 @@ Working with their test developers and other folks in the community, we develope


```yaml
- evalScript: ${output.foundElement = 0}
# Initialize state
- evalScript: ${output.foundElement = false}
- evalScript: ${output.retries = 0}

# Check if it's already visible
# Check if element is already visible
- runFlow:
when:
visible:
id: "the_thing_we_want"
commands:
- evalScript: ${output.foundElement = 1}
- evalScript: ${output.foundElement = true}

# Loop until found
# Loop until element is found or retries exhausted
- repeat:
while:
true: ${output.foundElement == 0}
true: ${!output.foundElement && output.retries < 10}
commands:
# Swipe up, from 90% down the screen to 75% down the screen
# Swipe vertically in the bottom portion of the screen (fragment-safe)
- swipe:
start: 50%, 90%
end: 50%, 75%
# Check if it's visible yet

# Wait for UI / animation to settle
- waitForAnimationToEnd

# Check visibility again
- runFlow:
when:
visible:
id: "the_thing_we_want"
commands:
- evalScript: ${output.foundElement = 1}
- evalScript: ${output.foundElement = true}

# Increment retry counter
- evalScript: ${output.retries += 1}

# Final assertion to ensure the element is visible
- assertVisible:
id: "the_thing_we_want"
```