Open saket opened 1 year ago
An official sample project from Google has some answers:
Are there any updates on this? It looks like the screenshots location for Gradle Managed Devices will differ from where Dropshots stores screenshots BUT from the linked Google project it does look like screenshots work.
Would it be possible to configure the gradle plugin to check for a different output folder to retrieve the screenshots?
Based on the answer here
Storing the result in Android/media/<Bundle Identifier>/additional_test_output
will fix this problem
private fun writeImage(name: String, filePath: String?, screenshot: Bitmap): String {
val externalStorageDir = Environment.getExternalStoragePublicDirectory("Android")
val screenFolder = File(externalStorageDir, "/media/${targetContext.packageName}/additional_test_output/screenshots".appendPath(filePath))
if (!screenFolder.exists() && !screenFolder.mkdirs()) {
throw IllegalStateException("Unable to create screenshot storage directory.")
}
val file = File(screenFolder, "${name.replace(" ", "_")}.png")
file.outputStream().use {
screenshot.compress(Bitmap.CompressFormat.PNG, 100, it)
}
return file.absolutePath
}
Dropshots doesn't seem to be able to generate snapshots when tests are run on managed devices. This can be reproduced in the sample app. Any ideas what might be happening?