scroll_to_text
Scroll on Android device screens to locate specific text content, supporting automated UI testing and development workflows.
Instructions
Scroll until text is found on screen
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| max_scrolls | No | ||
| device_serial | No |
Implementation Reference
- src/adb_mcp_server/server.py:482-496 (handler)The handler function for the 'scroll_to_text' tool. It repeatedly checks the UI hierarchy for elements containing the target text using find_element_by_text, scrolls down if not found, and returns the location when found or after max_scrolls attempts.@mcp.tool() def scroll_to_text( text: str, max_scrolls: int = 10, device_serial: str | None = None ) -> str: """Scroll until text is found on screen""" for i in range(max_scrolls): elements = find_element_by_text(text, partial_match=True, device_serial=device_serial) if elements: return f"Found '{text}' after {i} scrolls at {elements[0].get('center', 'unknown')}" scroll_down(device_serial) time.sleep(0.5) return f"Text '{text}' not found after {max_scrolls} scrolls"