What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Capture the screenshot inside the device-side test, save it as an artifact, and connect that capture to the failure hook supplied by your test runner or CI system. There is no single Android API that automatically captures the last frame for every kind of test. The implementation depends on whether you run an instrumented test on a device, a Firebase Test Lab test, or a host-side test such as Robolectric.
Choose the execution environment first
Android test APIs are not interchangeable. Identify where the test actually renders the UI before adding screenshot code.
| Environment | What it renders | Suitable capture route |
|---|---|---|
Instrumented UI test in src/androidTest/java |
A real emulator or device, including app and possible system UI | Modern UI Automator capture, or AndroidX Screenshot |
| Firebase Test Lab instrumentation | A device supplied by Test Lab | AndroidX Screenshot with FirebaseScreenCaptureProcessor |
| Robolectric or another JVM test | Host-side Android rendering | Use the framework’s rendering or screenshot facility; device-only UI Automator APIs do not apply |
| Golden-image test | A render compared with an approved reference | Screenshot comparison and review workflow, not an automatic substitute for failure diagnostics |
Instrumented tests run on a device or emulator and normally live in src/androidTest/java. Robolectric runs on the JVM, so a device screenshot API cannot be dropped into it unchanged.
Capture a failing state with modern UI Automator
The current UI Automator guide documents screenshots for the active window and for a selected element. Its modern API is marked under development, so verify the dependency version in your project’s catalog and the current Android documentation before pinning it. The guide’s sample uses androidx.test.uiautomator:uiautomator:2.4.0-alpha05; treat that as a versioned documentation example rather than a guarantee that it is the newest release.
#1 Best Overall
- Please note, this device does not support E-SIM; This 4G model is compatible with all GSM networks worldwide outside of the U.S. In the US, ONLY compatible with T-Mobile and their MVNO's (Metro and Standup). It will NOT work with other CDMA carriers, and it is also not compatible with their MVNO (Visible, Xfinity Mobile, US Mobile, Cricket Wireless, etc).
- Compatibility with certain third-party devices and accessibility accessories, including some hearing aids, may vary depending on manufacturer support, Bluetooth protocols, software compatibility, and regional firmware limitations. For additional hearing aid compatibility information, please refer to Samsung’s official support documentation.
- Camera: 50 MP, f/1.8, (wide), 1/2.76", 0.64µm, AF | 50 MP, f/1.8, (wide), 1/2.76", 0.64µm, AF | 2 MP, f/2.4, (macro). Battery: 5000 mAh, non-removable | A power adapter is NOT included.
Capture the active window
The following pattern captures after the UI has reached the state you want to diagnose, writes a bitmap to a file, and reports that file to instrumentation.
class CheckoutTest {
@Test
fun checkoutScreenCanBeInspected() {
val device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
val window = device.activeWindow()
val file = File(
InstrumentationRegistry.getInstrumentation().targetContext.cacheDir,
"checkout-window.png"
)
checkNotNull(window.takeScreenshot()).saveToFile(file)
ResultsReporter(instrumentation = InstrumentationRegistry.getInstrumentation())
.addFile("checkout-window", file)
.reportToInstrumentation()
}
}
Use the exact constructor and artifact method names from the version installed in your project; the important sequence is activeWindow(), takeScreenshot(), saveToFile, then ResultsReporter and reportToInstrumentation(). The resulting file is associated with the instrumentation result for inspection in Android Studio.
Capture one element instead of the whole screen
val checkoutButton = device.findObject(By.res("com.example.app:id/checkout"))
checkNotNull(checkoutButton).takeScreenshot().saveToFile(file)
Element capture is useful when a full-screen image contains sensitive or irrelevant content. Make the selector stable and wait until the element is displayed before capturing it.
Make capture conditional on failure
A screenshot call by itself is unconditional. Put it in the failure mechanism provided by your runner, JUnit integration, or CI wrapper, and verify that the hook runs for assertion failures, timeouts, process crashes, and instrumentation termination—the failure classes you care about. The Android documentation describes capture and reporting, but does not define one universal failure callback for every Android test framework.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesA practical arrangement is:
- Run the test body.
- In the framework-specific failure hook, call a helper that captures the active window or target element.
- Save with a unique name containing the test method and a timestamp.
- Report the file before the test process exits.
Do not claim that a JUnit rule, extension, or runner hook catches every process-level failure unless its documentation says so. A killed process or device disconnect can prevent any in-process cleanup code from running.
Rank #2
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
Use AndroidX Screenshot in Firebase Test Lab
Firebase Test Lab documents a separate processor flow for instrumentation tests. Register com.google.firebase.testlab.screenshot.FirebaseScreenCaptureProcessor as the instrumentation screen-capture processor, then call Screenshot.capture().process() in the test. Test Lab exposes processed images in the completed test’s Results view under Screenshots.
Register the processor
The guide supports registration through instrumentation manifest metadata or a runner argument. A metadata form is conceptually:
<application>
<meta-data
android:name="androidx.test.runner.screenshot.ScreenshotProcessor"
android:value="com.google.firebase.testlab.screenshot.FirebaseScreenCaptureProcessor" />
</application>
Use the exact metadata key and placement shown by the Firebase guide for your AndroidX Test Runner version. If your CI supplies runner arguments, configure the processor there instead of declaring it twice.
Capture from the test
import androidx.test.runner.screenshot.Screenshot
@Test
fun paymentFailureStateIsRecorded() {
// Drive the UI to the state that must be diagnosed.
Screenshot.capture().process()
}
For an activity-specific image, Firebase also documents Screenshot.capture(activity). If no processor is registered, AndroidX uses a basic screen-capture processor; that is different from Firebase’s Test Lab result integration.
Find the artifact
- Wait for the Firebase Test Lab test to complete.
- Open the test’s Results view.
- Select the Screenshots tab.
On Android 10/API 29 and higher, the documented Firebase screenshot read/write case does not require the legacy WRITE_EXTERNAL_STORAGE permission. Treat that as scoped to the documented configuration; storage behavior can change with target SDK, device image, and library versions.
Rank #3
- Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
- DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
- CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
- PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
- BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.
How to attach only failed-test screenshots
Keep diagnostic capture separate from normal evidence capture. A useful helper should accept the test name, capture scope, and destination, then return whether the artifact was actually written.
fun captureDiagnostic(name: String, device: UiDevice): File? {
val dir = File(
InstrumentationRegistry.getInstrumentation().targetContext.cacheDir,
"failure-screens"
).apply { mkdirs() }
val file = File(dir, "$name-${System.currentTimeMillis()}.png")
val bitmap = device.activeWindow().takeScreenshot() ?: return null
bitmap.saveToFile(file)
return file
}
Call this helper from your framework’s failure callback, then pass the returned file to the framework’s artifact reporter. If the callback itself fails, preserve the original test failure and log the capture error; diagnostics must not hide the assertion that caused the test to fail.
Free tools Windows power users keep installed
One-click scans. No signup required.
Diagnostic screenshots versus golden-image tests
A failure screenshot answers “what was visible when this test failed?” A golden-image test answers “does this render match an approved reference?” They solve different problems.
- Diagnostic capture: take an image only when a functional or synchronization test fails; inspect it to understand the state.
- Golden testing: compare a new render with a reference image using a defined pixel tolerance and a stable device, OS, font, density, and theme.
- Review: approve intentional UI changes and investigate differences caused by rendering, platform, or library drift.
A golden mismatch does not automatically prove a functional defect, and a golden test should not be presented as a universal way to retain the last screen from an arbitrary crash.
Common failure modes and fixes
No screenshot appears in the test result
- Confirm that the file was saved before the test process ended.
- Confirm that the artifact reporter was called after saving.
- Use a writable app cache or test output directory.
- For Test Lab, verify that the Firebase processor is registered and that you are viewing the completed test’s Screenshots tab.
The capture returns null or an empty image
- Wait for the target window or element to exist and be visible.
- Capture after the transition or animation has settled.
- Check that the test still has a connected device and that the app process has not crashed.
The code compiles in one module but not another
UI Automator device APIs belong in instrumented tests, not ordinary JVM tests. Move the test to src/androidTest, or use the host-side framework’s supported rendering API.
Rank #4
- YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
- LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
- MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
- NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
- BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.
Only some failures produce images
This is expected when the failure hook runs in-process. Assertion failures and handled exceptions usually permit cleanup; a device disconnect, process kill, or severe instrumentation failure may not. Record the limitation in CI and collect device logs separately.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →The screenshot is misleading
- Disable or wait for animations where your test policy permits.
- Capture the relevant element when system UI or transient overlays obscure the screen.
- Record device model, API level, orientation, locale, density, and theme with the artifact.
Performance, reliability, and security considerations
A PNG is larger and lossless; JPEG is smaller but can obscure small text and edges. Capture only on failure unless routine evidence is required. Use unique names to avoid concurrent tests overwriting each other, and clean temporary files after the runner has uploaded them.
Images can contain account names, tokens displayed in the UI, customer data, or personally identifiable information. Restrict artifact access, redact sensitive views before capture where possible, and set retention according to your organization’s policy. Do not log credentials or embed them in filenames.
For parallel device shards, include the shard, test class, method, API level, and timestamp in metadata. A screenshot without its execution context is difficult to reproduce.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Or skip the browser setup
If what you need is a screenshot of a web page, test report, or CI dashboard rather than the pixels rendered inside an Android device, ScreenshotNeo provides a single HTTP request. It removes cookie and consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, and timeouts are not billed, and the response identifies the page verdict and billing status in headers. Its MCP server gives AI agents tools named take_screenshot, get_page_info, and capture_pdf.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteRead the parameter and response details in the ScreenshotNeo API documentation. This cURL request saves a WebP image:
Best Value
- Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
- 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
- Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
- 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
- US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python:
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js:
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Create a free ScreenshotNeo account when a web-page capture endpoint fits your workflow.
Which approach should you use?
| Need | Best fit | Why |
|---|---|---|
| Inspect the complete device UI in a local instrumented test | UI Automator plus ResultsReporter | Captures an active window and reports the file to instrumentation |
| Inspect one control or region | UI Automator element screenshot | Reduces irrelevant content and artifact size |
| Run instrumentation on Firebase devices | AndroidX Screenshot plus Firebase processor | Images appear in Test Lab’s completed-test Screenshots view |
| Detect approved visual changes | Golden-image testing | Provides comparison and review rather than crash-state evidence |
| Capture a web page or hosted report | ScreenshotNeo | Clean shots, only clean shots billed, and a $5 paid entry plan |
Frequently Asked Questions
Does Android automatically save a screenshot whenever an instrumentation test fails?
No. Capture and failure handling are separate. Your runner, rule, extension, or service must call the screenshot code from a failure hook, and some process-level failures may prevent that hook from running.
Can I use UI Automator screenshots in Robolectric?
Not directly. UI Automator captures device or emulator UI; Robolectric is host-side. Use the host framework’s supported rendering or screenshot mechanism.
Where do Firebase Test Lab screenshots appear?
After the test completes, open its Results view and select Screenshots, provided the FirebaseScreenCaptureProcessor was registered.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

