How to get visible text from an EditText password (after PasswordTransformation - dots)?

I have a password field "Show password", and I want to write an integration test for it. How to verify that an EditText is really masked?

+5
source share
1 answer

You can check what the transformation displays with TransformationMethod.getTransformation (CharSequence, View). Instead of checking for zero, you should actually run the conversion and make sure that "textShown" is what you expect.

// EditText editText;
CharSequence realText = editText.getText();
CharSequence textShown = editText.getTransformationMethod().getTransformation(realText, editText);
0
source

All Articles