This QTP tutorial will explain two basic but important features of QTP which are used frequently in advanced QTP scripts. They are the QTP Password Encoder tool and the Active screen.
For obvious reasons websites do not display passwords even while we are providing it as an input to sign in. QTP has a unique feature that will preserve the password from being out in the open thus maintaining the password’s integrity.
QTP Password Tool
As you might have noticed when we enter the password as ‘Mercury’ in the flight’s application along and illegible sequence of characters is set in the password edit box.
This is how it looks:
In the above line of code we can see that the password is encrypted.
QTP records a ‘SetSecure’ method when a password is entered. It automatically encodes the password entered during login and decodes the same while running the test. This is a mechanism that QTP employs to hide the password on the screen.
The user can also choose to enter a value discreetly into a non-password text box by using the SetSecure method and an encrypted equivalent of the text to be entered as a parameter. If a need arises that we need to set a secure value in a certain textbox then QTP comes with a tool called ‘Password Encoder’. This tool will take a regular text and encodes it.
The “Password Encoder Utility’ is available at:
Start > Programs > HP QuickTest Professional > Tools > Password Encoder
It launches the following app:
The tool is very user-friendly and self-explanatory.
When the “Password” field is provided with an input, the “Generate” button becomes active and on clicking it, the encoded text is displayed in the “Encoded String” field. The same can be copied to the clipboard by clicking on the “Copy” button which gets enabled when the encoded password is generated.
The encoded text can be used as a direct input to a text/edit box or as a parameter in the DataTable.
This is another versatile feature that QTP provides to make the testing process more transparent to the user. While recording QTP saves a snapshot of the application state when a certain operation was performed on it. A number of details that you want your active screen to store and record depends on the settings.
Before we talk more about the settings and what it means let us take a look at how the active screen looks.
To view the active screen, click on “View->Active Screen”.
Here I have a test that creates a Gmail account and I chose to view the active screen. This is how it looks.
[Click to enlarge image]
As you can see, when I have the statement selected the corresponding object on which the statement acted upon is highlighted in the snapshot that the active screen has captured.
Let us see what happens when I move to the next statement, (Click to enlarge image)
The corresponding text box where I am trying to enter the First Name is highlighted and as it can be noted this is no longer the Gmail page, it is the ‘create a new Google account’ page.
Now let us see how much information can we ask QTP to store in this snapshot while recording and how do we do it.
Choose “Tools->Options->Active Screen” from the menu. It opens up the following window:
Each level of capture and its corresponding features are explained in this window. The default setting is as you see it in the screenshot.
The levels can be changed as required.
The following are the levels and what each level means gets displayed as the user sets them.
The capture level can be decreased or increased even after a test is created. Alternately the user can set a custom level of active screen capture by clicking on the “Custom Level” button and choosing the relevant options.
The active screen, apart from being a visual aid at the examining process also has several important aspects that can help the tester to manipulate the tests as required.
- The Objects in the Active screen can be added to the local or shared object repositories.
- Check-points can be added from this screen.
- Output values can be added
- Parameterization for the fields can also be done from this screen
- Steps can be added to the test
For Example, in our Gmail page earlier if I choose to add the ‘Sign in’ button to the repository I can do that by right-clicking on the object and the following options get displayed for me to choose from: (Click to enlarge image)
As you can see, I can insert a checkpoint, output value or choose to view or add objects among other things.
Although we are yet to uncover the checkpoint and output value features, it is inevitable to mention them here, as they are some key functionality that the active screen helps with.
Replacing the active screen for a certain step:
In case a need arises for me to change the active screen that got recorded by default, QTP provides me with a way to do that.
Choose the option “Tools->Change Active screen” from the menu and QTP lets you go to the new screen and when you click on the new screen, the control goes back to QTP with the following confirmation message: (Click to enlarge image)
On choosing “Yes” to this message, the new screen will be displayed henceforth when the active screen for that step is viewed.
If all the snapshots in your test have to be replaced or updated, you can choose to run the test in “Update Run mode”. You might be able to guess what this means, but in any case, we will have a detailed discussion on it later on in the coming articles.
Real-time use of the active screen is when you want to make changes to the test without opening your application but just from the screen captured during the record.
Although it must be noted that tests with Active screen-captured occupy way more disk space than the ones without it. On saving a test using “Save as” an option to exclude Active screen is available to the user.
So what you can do is, record a test with an active screen, modify it as needed while leveraging as many features as you can from it and “Save as” a new test without the active screen. This ensures that your tests are easy on disk space at the same time you get to use the active screen to your benefit while it was needed.
This is some brief insight into the topics, password encoder, and Active screen.
The next article is going to be about an Expert view, Step generator, and we will try to include some checkpoints too. Please feel free to post your questions.