Using Native Screenshots for Better Debugging
On This Page How do Native Screenshots for Debugging help?January 03, 2026 · 7 min read · Testing Guide
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? Goal of Using Native Screenshots for Debugging Benefits of Native Screenshot Debugging Business Impact of Screenshot-Based Debugging 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. 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 – 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. 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. 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 – 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. For native Screenshot of testing a aboriginal app, the step are: 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. 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: 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. # Ask-and-Contributeabout this topic with our Discord community. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed. Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.Using Native Screenshots for Better Debugging
Overview
How do Native Screenshots for Debugging assistance?
How to test your Native Apps?
Testing the Native Apps habituate BrowserStack
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
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;}}}@ 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 '');}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
Related Guides
Automate This With SUSA
Test Your App Autonomously