Most of the applications/websites will require a password for getting into them.
So, automation tools such QTP should be able to handle the passwords. But anyway, it is not a good practice to keep the password as it is in the scripts.
By default QTP will encrypt the password while recording. The recorded step will look like the below statement.
SetSecure method will be specifically used for handling passwords.
This recording approach will be useful only when you are going to use one or few passwords in your script.
If you want to use many number of different passwords for executing many iterations, this recording approach won't be much useful.
In this case we can use password encoder utility provided by QTP.
It can be accessed from start menu (e.g Programs->Quick Test Professional->Tools->Password Encoder)
It will look like below screenshot.
We need to enter the password text, and clicking "Generate" button will provide the encoded password string.
We can put this string in the Datatable for executing multiple iterations with different passwords.
It will be useful not only for automating the testing, but also in below scenario.
- you want to allow a person available in a remote place to get into your application/site for doing some testing or for some other purpose, and you don't want to share the password with him. In this case you can just create a QTP script to log into the application.
Some people may not be willing to store the password in the QTP script even in the encrypted form also.
In this case, we can create a simple HTML form and call it from QTP script to show as a pop-up window for getting password from user while executing the Script.
eBook for learning Software Testing and QTP Automation.