Take a screenshot on Android Espresso Test Failure

  1. Create a new folder in androidTest/utility/screenshot
  2. Add these two files EspressoScreenshot.kt and ScreenshotTestRule.kt to the folder (shown below).
  3. Add write permission to Manifest, to save the screenshot file in the device.
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store