Can I verify that an input field is masked or shows the text?


Using Java and webdriver, I’m trying to setup a test to verify that the password I type is masked. With my tool, we have a setting that allows you to have the password masked or to show the text. I was wondering if anyone has ever verified something like this with Selenium.

Here is what I want to check
Setting OFF – type into the input field and verify that text is displayed
Setting ON – type into the input field and verify that my input is masked

I believe the browser handles masking, so I’m not sure if I can do this test or not. The element for the input field does not have any attributes about masking.

Thanks for your help


Check the type property if the input, if it’s text the text is not masked, if it’s password it is masked.

Answered By – Maurício Linhares

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published