Pages

Showing posts with label Encrypt. Show all posts
Showing posts with label Encrypt. Show all posts

Tuesday, November 13, 2012

Quick Test Professional (QTP) - Utility Objects

QTP provides several utility objects to enhance the power of scripting. Below is a list of all QTP utility objects.

Crypt, DataTable, Description, DTParameter, DTSheet, Environment, Extern, OptionalStep, Parameter, PathFinder, Properties(Collection), QCUtil, Random Number, Recovery, Reporter, Services, Setting, TextUtil, TSLTest, XMLUtil

Only some of the QTP objects are covered here and rest will be covered in other post.


Quick Test Professional (QTP) - Crypt Object


This object encrypts strings in a format that the QTP SetSecure function understands. Encrypt is the only method provided by the object.

'Encrypt the string
myVar = Crypt.Encrypt("QTPText")

The above statement will assign myVar a value which looks something like
"456955244855c54535454f5455784456f66446s7r464a64r64kj464b6467h443g3234"

This value produced by Crypt.Encrypt is not constant because encrypting the same string again generates a different encrypting string. Now the question arises that when should this capability be used? Consider a script which is executed on a tester's PC with the results sent to others. Is the script has a step top enter a password:

'Set the text in the WebEdit
Browser("Browser").Page("Page").WebEdit("password").Set "QTP"

Then this step will appear in the result summary and will include the "QTP" value. This could compromise security, so let's replace the above statement with a new one:

'Encrypt and then set the password
sEncryptPassword = Crypt.Encrypt("QTP")
Browser("Browser").Page("Page").WebEdit("password").SetSecure sEncryptPassword

Now the password won't appear in the test result summary as we are using the secure mode of setting the password.

NOTE: We can also create an instance of the crypt object is VBScript using the following code :
Set myCrypt = CreateObject("Mercury.Encrypter")