If you experience issues finding UI elements for an Android app, it might be that the developer has used an Android security feature in their app to block taking screenshots, so the UI elements are protected and not accessible.
If this is the case, you'll see this in the device log when trying to take a screenshot during a test:
W SurfaceFlinger : FB is protected: PERMISSION_DENIED
Our tests show the following:
Android 6.0
Video and screenshot work
Android 7.0 & 8.0
Video works but not screenshot
(Video on EMUSIM works because its of the entire VM as opposed to just the screen)
Android 9.0, 10.0 and beyond
Video and screenshot don't work
(Video on EMUSIM works because its of the entire VM as opposed to just the screen)
This behavior is seen not only via Appium but also via native adb commands like:
adb shell screencap
adb shell screenrecord
This is relevant to testing on any emulator/real device and therefore is not a Sauce Labs specific issue but a Android OS security feature.