UI Debugging
A step-by-step workflow for diagnosing UI issues using component tree inspection, element queries, and state inspection.
Scenario
A user reports that the "Add to Cart" button on the product detail screen doesn't respond. Let's investigate.
Step 1: Take a snapshot
Start by capturing the component tree to understand the current screen structure.
This returns the full component tree with UIDs, types, testIDs, and text content. Look for the button in the tree output.
Step 2: Find the button
Use query_selector to locate the button element and get its measurements.
Example response:
If the button is found, check:
- Is it positioned off-screen? (
pageYbeyond screen height) - Does it have zero dimensions? (
width: 0orheight: 0) - Is it overlapped by another element?
Step 3: Check for overlapping elements
If the button exists but doesn't respond to taps, something might be covering it. Query for elements at the same position.
Then use describe_ui to check the native accessibility tree at that point:
Step 4: Inspect component state
Check the component's internal state to see if it's disabled or in a loading state.
Example response:
Found it — hook index 1 shows "out_of_stock", which likely disables the button.
Step 5: Track state changes
Monitor state changes while interacting with the app to understand the flow.
Now interact with the app (navigate, tap, etc.), then check what changed:
Step 6: Check console for errors
Look for related error messages in the console.