capturing-screenshots-and-screenrecord
Installation
SKILL.md
Capturing Screenshots and screenrecord — Visual Artefacts For Tests
This skill covers grabbing PNG screenshots and MP4 screen recordings from a device through adb, plus the JUnit4 TestWatcher pattern for capturing on test failure. It does not cover Android Studio's screenshot tool, Compose captureToImage(), or third-party streaming tools (scrcpy/Vysor).
When to use this skill
- A flaky CI test needs a screenshot at the moment of failure plus a logcat dump.
- The team generates golden screenshots from a reference device for visual regression.
- QA needs to record a 30 s repro of a bug for a bug report attachment.
- The dev's
adb shell screencap /sdcard/out.pngproduces a corrupt file — the missing-pflag wrote raw RGBA, not PNG. - A Windows CI agent receives screenshots with CRLF corruption — the fix is
adb exec-out screencap -p.
When NOT to use this skill
- Compose-level screenshot tests using
captureToImage()/ Roborazzi / Paparazzi. Those are unit-test mechanisms and live under the Compose set, not ADB. - Continuous live mirroring of the device (presentations, demos). Use scrcpy or Vysor —
screenrecordcannot stream. - Driving the device first (taps, key events). Use
../../control/injecting-input-and-state/SKILL.md. - Pulling files generally (not screenshots). Use
../../transfer/extracting-test-artifacts/SKILL.md.