Repository navigation
Fix negative bounds, off-screen filtering, and multiline labels in Android screen.py - #28
Merged
pierridotite merged 1 commit intoNov 26, 2026
Conversation
Owner
|
Merged, thanks! Good catch on the missing minus sign, that phantom button in the middle of the screen was a nasty one. I also ran the replay check on an emulator after the merge and it still passes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
scripts/android/screen.pycurrently parses UIAutomatorboundswithre.findall(r"\d+", ...)instead ofr"-?\d+"(the only bounds parser in the repo missing-?—a11y.py,ecr_trace.py,dashboard.py, andcrawl.pyall parse signed integers).Because negative signs are dropped and bounds are not checked against the viewport:
bounds="[-900,400][-100,600]"(true centre(-500, 500)) is printed as- button "Hidden Left Card" centre=(500,500), creating a phantom tap target in the middle of the screen.bounds="[-200,700][400,900]"has its centre shifted right from(100, 800)to(300, 800).[0,0][0,0]) and off-screen ([100,2600][980,2800]) nodes are listed as tappable elements.textorcontent-desc(e.g."Send\nTab 2 of 3") break the one-element-per-line listing.Solution
elements(root, w, h)inscripts/android/screen.py(withmain(argv=None)underif __name__ == "__main__":andfrom PIL import Imageinsidemain(), matchingscripts/web/screen.pyso unit tests run cleanly without Pillow).r"-?\d+", skip zero-size/inverted bounds (x2 <= x1 or y2 <= y1), and skip elements whose centre(cx, cy)falls outside the physical screen viewport(0 <= cx <= w and 0 <= cy <= h)(matchingscripts/ios/screen.pyandscripts/web/page_js.py, usingw, h = img.sizebefore the half-size resize).textandcontent-descwith" ".join((...).split())so multiline labels stay on one line and whitespace-onlytextfalls back tocontent-desc.adbCLI test intests/test_android_screen.py, updatetests/test_ecr_replay.pyto invokeelements()directly, and add a line toCHANGELOG.md(## Unreleased).Verification
/usr/bin/python3 -m unittest discover -s tests -q(Python 3.9.6): 275 tests OK (3 opt-in Playwright tests skipped)PILmasked): 8/8 unit tests pass (only stub-adbPillow test skipped)