Appium — Dealing with FLAG_SECURE enabled in application
Applications like Netflix do not allow users to capture screen by enabling FLAG_SECURE ON. This is often done due to security constrains, most of the banking applications also do not allow you to take screenshots of application. In such cases, While trying to automate we wont be able take Screen dump via UiAutomator viewer or using Appium desktop however for testing purposes developers can make a debug build that has FLAG_SECURE flag removed/turned off.
If it’s not possible to turn off the FLAG , one approach we can follow is using driver.getPageSource() from Appium client code which will return element hierarchy in XML which you can use for building locator.
String elementHierarchy = driver.getPageSource();
Once you get the elementHierarchy you can find necessary elements, it wont be as convenient as it would be with UiAutomator viewer or using Appium desktop but still very much possible.
Hope this helps , Happy coding ❤