Fix scroll direction and handle OpticsError in scrolling logic#316
Conversation
- correct vertical swipe coordinates by swapping up/down branches
retry loop - The assert_presence call throws OpticsError(Code.E0201) when the element is not found, which killed the while loop on the first miss. Wrap in try/except to catch only E0201(element not found) so the loop continues scrolling until timeout. Re-raise any other OpticsError codes
There was a problem hiding this comment.
Pull request overview
This PR adjusts mobile scrolling behavior and makes scroll_until_element_appears resilient to element-not-found errors raised by the strategy layer, so scrolling can continue until timeout.
Changes:
- Fixes the
up/downcoordinate mapping in the Appium driver’sscroll()gesture. - Wraps
verifier.assert_presence(...)inscroll_until_element_appearswith anOpticsErrorhandler to ignoreE0201(element not found) while continuing to scroll.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| optics_framework/engines/drivers/appium.py | Updates swipe start/end Y coordinates to correct up vs down scroll direction behavior. |
| optics_framework/api/action_keyword.py | Catches OpticsError during scroll-until-present loop so E0201 doesn’t abort scrolling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Chinmay Jha <chinmayajha@gmail.com>
|
@kun-codes add a unit test pertaining to this. |
|
@chinmayajha added unit tests |
| elif direction == "down": | ||
| start_x = width // 2 | ||
| start_y = int(height * 0.2) | ||
| end_y = int(height * 0.8) |
There was a problem hiding this comment.
a good part you picked.
it would be great if we unify the standard for this in docs across all drivers
for example
- do we follow scroll movement -> if user scrolls down -> page goes down
or
2. do we follow swipe movement -> if you swipes down -> page goes up
or a mix of both
There was a problem hiding this comment.
alright I will add this to the TODO
|



optics_framework/engines/drivers/appium.pyOpticsErrorerror code E0201 which corresponds to element location issues inoptics_framework/api/action_keyword.pyThe call chain which leads to
OpticsErroris:I have tested out my pull request on an Android device