Say we have an app named NoseBook
, this app doesn't has the permission of android.permission.WRITE_EXTERNAL_STORAGE
and we don't intent to request user for this permission.
uiautomator2
is the selected blackbox test framework, and we're trying to capture a screenshot during the test and save it somewhere, which later can be pulled from AVD and saved as report.
The API called is UiDevice#takescreenshot but the following error was shown
E/UiDevice: failed to save screen shot to file
java.io.FileNotFoundException: /storage/emulated/0/test.png (Permission denied)
The error will go away if we add the WRITE_EXTERNAL_STORAGE
to the app NoseBook
but it is not appropriate as this is only for our testing purpose, the actual app doesn't need that permission.
Note: screencap is the workaround i've noticed but I'm looking solution around uiautomator
itself.
Environment: emulator API 25