Skip to content

Widget not placed in automated screenshot (UIAutomator drag silently no-ops) #5

Description

@digitalby

Observed

The screenshot CI workflow (feature/real-screenshots) goes green and produces fastlane/metadata/android/en-US/images/phoneScreenshots/01_widget.png, but the captured image shows a bare home screen with no widget on it.

Root cause

WidgetScreenshotTest.placeWidget() uses UIAutomator2 selectors that find something in the Launcher3 widget picker but don't actually land the widget on the home screen. The instrumentation exits 0 because no error() call is reached (the selectors succeed individually), but the drag either targets the wrong element or drops it outside the home grid.

Likely causes:

  • By.res("com.android.launcher3:id/workspace") may resolve to the outer container, making the long-click land on a wrong target (or open the app drawer instead of the widget picker)
  • By.textContains("Debug Mode") in the widget picker may match the app header label but not the actual draggable widget preview tile
  • The drag destination (displayWidth/2, displayHeight/4) may be outside the safe drop zone of the grid

Fix direction

  1. Dump the UI hierarchy (uiautomator dump) during the widget picker step to identify the correct resource IDs and class names for API 33 Launcher3
  2. Use By.clazz("android.widget.TextView").text("Widgets") or By.res("com.android.launcher3:id/widget_button") for the picker trigger
  3. For the widget tile, use the exact resource ID of the draggable preview cell in the picker
  4. After the drag, assert that a view with package info.yuryv.androiddebugmode is present on the home screen before taking the screenshot

Related

Branch: feature/real-screenshots
Workflow: .github/workflows/screenshots.yml
Test class: app/src/androidTest/java/info/yuryv/androiddebugmode/screenshot/WidgetScreenshotTest.kt

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions