Skip to content

Fix scroll and scrollUntilVisible on Android#28

Open
maggialejandro wants to merge 1 commit intodevicelab-dev:mainfrom
maggialejandro:fix/scroll-until-visible-android
Open

Fix scroll and scrollUntilVisible on Android#28
maggialejandro wants to merge 1 commit intodevicelab-dev:mainfrom
maggialejandro:fix/scroll-until-visible-android

Conversation

@maggialejandro
Copy link

@maggialejandro maggialejandro commented Mar 3, 2026

Summary

  • Use ADB input swipe for reliable scrolling instead of Appium gestures, which are unreliable on many Android devices/emulators
  • Distinguish "element not found" errors from infrastructure failures (connection refused, dead sessions) in scrollUntilVisible — connection errors are now propagated immediately instead of being silently swallowed
  • Log a warning when falling back to the unreliable Appium scroll path due to missing ADB
  • Fix duplicate error messages in errorResult calls

Test plan

  • Existing TestScrollUntilVisible* tests pass
  • New TestScrollUntilVisibleConnectionError verifies early bail-out on connection errors
  • New TestIsElementNotFoundError covers the not-found error allowlist
  • Manual verification on Android device/emulator

🤖 Generated with Claude Code

Copy link
Contributor

@omnarayan omnarayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Contributor

@omnarayan omnarayan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thanks for the PR — the ADB swipe fix makes sense and the before/after videos are great.

A couple things before we merge:

Too much formatting noise — most of the diff is gofumpt reformatting (octal literals, alignment) across files that have nothing to do with scrolling. Can you pull those out into a separate commit or PR? It makes the actual fix really hard to review.

Errors getting swallowed — in scrollUntilVisible, when findElement fails we just keep scrolling. That's fine if the element isn't found yet, but if the driver connection dies or the session crashes, we'd silently loop through all scrolls and report "element not found" instead of the real error. Worth distinguishing "not found" from actual failures.

Silent fallback to Appium — the whole point of this PR is that Appium scroll doesn't work, but scrollBySwipe quietly falls back to it when there's no ADB. Should at least log a warning there so we know when we're hitting the broken path.

Minor — in scroll(), the error shows up twice in the return (err + fmt.Sprintf("Failed to scroll: %v", err)).

The core fix is solid, just needs a cleanup pass!

@maggialejandro maggialejandro force-pushed the fix/scroll-until-visible-android branch from 4ec7fa6 to b32f2e3 Compare March 3, 2026 20:55
@omnarayan
Copy link
Contributor

@maggialejandro we are also working on new driver and it might do better that adb, please try out

I have created an interim build

curl -fsSL https://open.devicelab.dev/install/maestro-runner | bash -s -- --version 1.0.8-rc4

To use it with the new driver:

maestro-runner --driver devicelab --device <DEVICE_SERIAL> test <flow.yaml>

@maggialejandro maggialejandro force-pushed the fix/scroll-until-visible-android branch from b32f2e3 to 03d1105 Compare March 3, 2026 21:12
@maggialejandro maggialejandro changed the title Fix scroll and scrollUntilVisible on Android using ADB input swipe Fix scroll and scrollUntilVisible on Android Mar 3, 2026
@maggialejandro
Copy link
Author

Hey! Thanks for the PR — the ADB swipe fix makes sense and the before/after videos are great.

A couple things before we merge:

Too much formatting noise — most of the diff is gofumpt reformatting (octal literals, alignment) across files that have nothing to do with scrolling. Can you pull those out into a separate commit or PR? It makes the actual fix really hard to review.

Errors getting swallowed — in scrollUntilVisible, when findElement fails we just keep scrolling. That's fine if the element isn't found yet, but if the driver connection dies or the session crashes, we'd silently loop through all scrolls and report "element not found" instead of the real error. Worth distinguishing "not found" from actual failures.

Silent fallback to Appium — the whole point of this PR is that Appium scroll doesn't work, but scrollBySwipe quietly falls back to it when there's no ADB. Should at least log a warning there so we know when we're hitting the broken path.

Minor — in scroll(), the error shows up twice in the return (err + fmt.Sprintf("Failed to scroll: %v", err)).

The core fix is solid, just needs a cleanup pass!

Thanks for the thorough review!

All addressed:

  • Swallowed errors — scrollUntilVisible now distinguishes "not found" errors from infrastructure failures (connection refused, dead sessions, etc.) and bails out immediately on the
    latter instead of looping through all scrolls.
  • Silent Appium fallback — Added a logger.Warn when scrollBySwipe falls back to Appium due to missing ADB.
  • Duplicate error message — Fixed the redundant err + fmt.Sprintf("...: %v", err) in the errorResult calls.

Also squashed the scroll fix into a single commit to keep history clean.

Let me know if anything else needs adjusting!

Use ADB input swipe for reliable scrolling instead of Appium gestures,
which are unreliable on many Android devices/emulators. Log a warning
when falling back to the Appium scroll path due to missing ADB.

Also distinguish "element not found" errors from infrastructure failures
in scrollUntilVisible so connection errors are propagated immediately
instead of being silently swallowed until all scrolls are exhausted.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maggialejandro maggialejandro force-pushed the fix/scroll-until-visible-android branch from 03d1105 to 73a08cd Compare March 3, 2026 21:19
@codecov
Copy link

codecov bot commented Mar 3, 2026

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment

Thanks for integrating Codecov - We've got you covered ☂️

@maggialejandro
Copy link
Author

@maggialejandro we are also working on new driver and it might do better that adb, please try out

I have created an interim build

curl -fsSL https://open.devicelab.dev/install/maestro-runner | bash -s -- --version 1.0.8-rc4

To use it with the new driver:

maestro-runner --driver devicelab --device <DEVICE_SERIAL> test <flow.yaml>

1.0.8-rc4 is not working for me.

73a08cd

Screenshot 2026-03-04 at 10 00 00 AM

Android 1.0.8-rc4

Screenshot 2026-03-04 at 10 15 26 AM

iOS 1.0.8-rc4

Screenshot 2026-03-04 at 10 16 10 AM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants