Finding android element when FLAG_SECURE enabled in application

Banking apps and such tend to use FLAG_SECURE for safety reasons, so that the screen can not be captured or recorded. In such cases we are not able take Screen dump via UiAutomator viewer. How to see identify the element in such a cases. How to appium automate such apps ?

I would guess they make a debug build that has this flag removed/turned off.

If there isn’t an option to disable the security (as I have in our checkout flows), it can be painful. Luckily you can still get the screen source. So it’s a bit more manual. You can still use the UiAutomatorView I believe, it’s just all black, and then just click where you know the element is. Or just start a test that all it does it get you to the screen and take a source dump, and look through that for the items you need. Annoying, but works.

FLAG_SECURE only blocks capture screenshot, you can not use UIAutomatorViewer or Appium inspector because they both takes screen snapshot. However you should be able to get element hierarchy by driver.getPageSource() in debug mode. It returns XML which you can use for building locator.

2 Likes

Thanks this works for me

Please help me to solve same problem where , my screenshot is not taken by appium inspector or UI automator only messsage diplay about secure flag.