Using Native Screenshots for Better Debugging

On This Page How do Native Screenshots for Debugging help?January 03, 2026 · 7 min read · Testing Guide

Using Native Screenshots for Better Debugging

Different ways are available to help you in debugging, such as to exactly mold any anomaly. Furthermore, using screenshots for debugging, you can besides pinpoint where the software is experiencing a failure.

This abnormalcy is either regard the execution of the app. Or this fault could also be causing the malfunctioning of the app in any way that you, as a developer or a tester, did not expect to bechance. And do you know what could be the worst thing in this case?

Overview

Goal of Using Native Screenshots for Debugging

  • Simplify app debugging with screenshots that capture anomalousness.
  • Detect UI and functional subject faster without additional test code.
  • Enable precise bug track with screen-level context in test performance.

Benefits of Native Screenshot Debugging

  • UI Validation:Identify layout, designing, and rendering issues instantaneously.
  • Functional Clarity:Pinpoint the exact failure screen during app execution.
  • Improved Debugging:Combine screenshots with logs, picture recordings, and twist data for deeper insights.
  • Framework Support:Works seamlessly with Espresso, Appium, XCUITest, and Flutter.
  • Cost Savings:Eliminate the motivation for large twist farms by leverage BrowserStack ’ s Real Device Cloud.

Business Impact of Screenshot-Based Debugging

  • Faster bug detection and resolution.
  • Reduced QA effort and manual investigation.
  • Improved release quality with real-time visibility of defect.
  • Greater confidence to ship apps across platforms.

This could be a minor bug hidden in one of the hundreds of files between those thousand lines of codification. However, with, you can use screenshots to discover the highly-developed app ’ s glitch.

How do Native Screenshots for Debugging assistance?

Any case can oblige a tester to use screenshots for debugging as it becomes good in simplifying the process. Screenshots also identify any issues related to the UI & # 8211; the layout or any design-related problems in the app- without writing any test codification.

These Screenshots for debug can too be captured on BrowserStack App Automate, where you will be able to debug and fix the by using –

  • Screenshots aids
  • Video recording aids
  • A range of log pointing out the code mistake

Not only these, but you can also configure the options for debugging as per your needs while running your Espresso tests. For those not into coding, Espresso Test Recorder create for your app without writing any code.

You need a costly to run the Espresso tests on multiple real devices. But by opt for testing on a Existent Device Cloud on BrowserStack. Access 3000+ device-browser-OS combinations.

How to test your Native Apps?

For autonomous testing across multiple user personas, check out SUSATest — it explores your app like 10 different real users.

App Automate can provide testing with the help of screenshots while testing both hybrid and native covering. With excellent twist coverage, including the latest flagship device from Android and iOS, teams can integrate & # 8211; Appium, Espresso, XCUITest, or Flutter, with diverse Test Dev surroundings.

  • You can also quiz under like mesh simulation, geolocation testing, in-app purchases, push notifications, and preloaded images.
  • In add-on, you can easily debug your apps immediately with the help of device and text log, screenshots, and video recordings for every test performance instance.

Read More:

Prerequisites for testing the aboriginal apps use Espresso

For testing your app build, you need to have the following things in your inventory –

  • A mobile OS like an Android OS or iOS:It will help in initiating the execution for your app
  • A URL of the file if it is stored on the cloud:If your app has be stored on the cloud and not on the local host, so a URL of the app is also helpful.
  • A BrowserStack Account:A BrowserStack Account afford your the access keys required to connect to prove platform

Testing the Native Apps habituate BrowserStack

To prove the aboriginal app, you need to. You can capture screenshots for your Espresso trial by utilizing the Spoon framework. The native screenshots can help encounter the precise screen where the abnormal activity or the failure come. You will likewise be capable to see if there are any UI bugs in the codification.

To enable screenshots seizure using Spoon model, you must surpass theenableSpoonFrameworkparameter in the REST API request. This will begin the Espresso trial performance.

Given below is an example.

curl -u `` YOUR_USERNAME: YOUR_ACCESS_KEY '' \ -X POST `` https: //api-cloud.browserstack.com/app-automate/espresso/v2/build '' \ -d ' {`` enableSpoonFramework '': true, `` devices '': [`` Samsung Galaxy S8-7.0 ''], `` app '': `` bs: //f7c874f21852ba57957a3fdc33f47514288c4ba4 '', `` testSuite '': `` bs: //e994db8333e32a5863938666c3c3491e778352ff ''} ' \ -H `` Content-Type: application/json ''

Steps to captivate Screenshots in your Espresso exam

For native Screenshot of testing a aboriginal app, the step are:

  • creating NativeScreenshot.java in your projection directory. add the code that is given below:
import android.graphics.Bitmap; import android.os.Build; import android.os.Environment; signification androidx.test.runner.screenshot.BasicScreenCaptureProcessor; import androidx.test.runner.screenshot.ScreenCapture; import androidx.test.runner.screenshot.Screenshot; signification java.io.File; import java.io.IOException; import java.util.regex.Pattern; public final class NativeScreenshot {private static String methodName; individual static String className; private electrostatic final Pattern SCREENSHOT_NAME_VALIDATION = Pattern.compile (`` [a-zA-Z0-9_-] + ''); private NativeScreenshot () {} / * * * Captures screenshot using Androidx Screenshot library and stores in the filesystem. * Exceptional Cases: * If the screenshotName contains infinite or does not surpass validation, the corresponding * screenshot is not visible on BrowserStack 's Dashboard. * If there is any runtime exception while capturing screenshot, the method drop * Exception and the test might fail if elision is not treat properly. * @ param screenshotName a screenshot identifier * @ return path to the screenshot file * / public static String capture (String screenshotName) {StackTraceElement testClass = findTestClassTraceElement (Thread.currentThread () .getStackTrace ()); className = testClass.getClassName () .replaceAll (`` [^A-Za-z0-9._-] '', `` _ ''); methodName = testClass.getMethodName (); EspressoScreenCaptureProcessor screenCaptureProcessor = new EspressoScreenCaptureProcessor (); if (! SCREENSHOT_NAME_VALIDATION.matcher (screenshotName) .matches ()) {throw new IllegalArgumentException (`` ScreenshotName must match `` + SCREENSHOT_NAME_VALIDATION.pattern () + ``. ``);} else {ScreenCapture capture = Screenshot.capture (); capture.setFormat (Bitmap.CompressFormat.PNG); capture.setName (screenshotName); try {regress screenCaptureProcessor.process (capture);} catch (IOException e) {throw new RuntimeException (`` Unable to capture screenshot. ``, e);}}} / * * * Extracts the presently execute test 's trace element based on the test runner * or any framework be utilize. * @ param trace stacktrace of the currently escape test * @ return StackTrace Element correspond to the current test being executed. * / individual static StackTraceElement findTestClassTraceElement (StackTraceElement [] trace) {for (int i = trace.length - 1; i & gt; = 0; -- i) {StackTraceElement element = trace [i]; if (`` android.test.InstrumentationTestCase '' .equals (element.getClassName ()) & amp; & amp; `` runMethod '' .equals (element.getMethodName ())) {return extractStackElement (trace, i);} if (`` org.junit.runners.model.FrameworkMethod $ 1 '' .equals (element.getClassName ()) & amp; & amp; `` runReflectiveCall '' .equals (element.getMethodName ())) {regress extractStackElement (trace, i);} if (`` cucumber.runtime.model.CucumberFeature '' .equals (element.getClassName ()) & amp; & amp; `` run '' .equals (element.getMethodName ())) {retrovert extractStackElement (touch, i);}} throw new IllegalArgumentException (`` Could not find test course! ``);} / * * * Based on the test runner or framework being used, extracts the exact traceElement. * @ param trace stacktrace of the currently go test * @ param i a quotation index * @ return shadow element establish on the power passed * / private static StackTraceElement extractStackElement (StackTraceElement [] trace, int i) {int testClassTraceIndex = Build.VERSION.SDK_INT & gt; = 23? i - 2: i - 3; render shadow [testClassTraceIndex];} private unchanging class EspressoScreenCaptureProcessor extends BasicScreenCaptureProcessor {private static final String SCREENSHOT = `` screenshots ''; EspressoScreenCaptureProcessor () {File screenshotDir = new File (String.valueOf (Environment.getExternalStoragePublicDirectory (Environment.DIRECTORY_DOWNLOADS)), SCREENSHOT); File classDir = new File (screenshotDir, className); mDefaultScreenshotPath = new File (classDir, methodName);} / * * * Converts the filename to a standard way to be store on device. * Example: `` post_addition '' converts to `` 1648038895211_post_addition '' * which is later suffixed by the file extension i.e. png. * @ param filename a screenshot identifier * @ return usage filename format * / @ Override protect String getFilename (String filename) {return System.currentTimeMillis () + `` _ '' + filename;}}}

This is how you can edit your to take aboriginal screenshots

After that you postulate to call the NativeScreenshot.capture (& # 8220; tag & # 8221;) method. This will help you to capture the screenshots from your Espresso tests. The sample code has been provide in the snip.

The tag parameter gives a name to the screenshot, which is stored in you ’ re particular page of session detail.

@ Test public vacancy ensureAdditionWorks () {// examination actions onView (withId (R.id.buttonOne)) .perform (click ()); onView (withId (R.id.buttonTwo)) .perform (click ()); onView (withId (R.id.buttonAdd)) .perform (click ()); // other test activeness ... onView (withId (R.id.editText)) .check (matches (withText (`` 33 ''))); // capture the screenshot and add the 'post_addition ' tag to the screenshot NativeScreenshot.capture (`` post_addition '');}

Add the debug screenshots argument in the REST API request to enable screenshots on your Espresso test session.

The following sample cURL dictation shows the parameters used to enable screenshots on Android v7.1:

curl -u `` contentusdigital_6BJuGt: RCQgysY5ofpxBvsEQayp '' \ -X POST `` https: //api-cloud.browserstack.com/app-automate/espresso/v2/build '' \ -d ' {`` debugscreenshots '': true, `` devices '': [`` Google Pixel-7.1 ''], `` app '': `` & lt; app_id & gt; '', `` testSuite '': `` & lt; test_suite_id & gt; ''} ' \ -H `` Content-Type: application/json ''

View Screenshots of the Test Execution

Now you need to navigate to the splasher. On your session detail page, you feature to click on theScreenshotstab to consider screenshots for every test case.

An model is given in the following image:

Wrapping Up,

Hopefully, this write-up has disgorge light on the functioning of BrowserStack and how it can do a touchable difference towards better debugging. Moreover, with BrowserStack, you can access more than 3000+ real devices and browser, to run your tests, identify bugs or other anomalies and happen firmness to deliver the best possible production.

Tags
67,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free