Search code examples
selenium-webdriverrobotframework

Verifying a text box hides its contents with Robot Framework SeleniumLibrary


I'm trying to create a test in Robot Framework to verify password protections on this system and, as part of that, I want to verify that the password field is appropriately obfuscating the contents. i.e.: when I type in "asdf" I want to know for certain it is displaying "●●●●" like any other password field. My assumption was that I could retrieve the obfuscated text using SeleniumLibrary's Textfield Should Contain keyword but to my surprise - and relative alarm - the keyword actually returns the original text entered (i.e.: "asdf"). How can I get the literal text being shown by the input field?


Solution

  • If you want to confirm that the browser is working fine (not your application), you can use an image recognition library like SikuliLibrary, capture the element and confirm that your content asdf is not recognized. (I am almost sure, that this is not your testing requirement ;) )

    The way you are testing, is getting the content provided to your app from the input element of type="password". This is HTML, and how the password content can be passed to the processing of the application. It is normal to get the value and not the symbols shown to the user.

    You should experiment:

    1. Type your asdf password in the password field
    2. Open the browser tool - DevTool, i.e. pressing F12
    3. Locate the password field in the HTML (DOM)
    4. Change the input element type="password" to type="text"

    As result the password asdf is now visible.