Wednesday, July 20, 2011

DataTable Parameterization in QTP

Data Table parameters enable you to create a data-driven test/ action that runs several times using the data you supply. i.e., each iteration qtp takes a new value from data table.

Parameterization can be done through:
  • Expert View
  • Keyword View
  • Data driver wizard
  • Object repository
Assume that User name and Password fields in Login page should be tested with different sets of test data, then instead of creating script for each set of data, we just create a script with one set of data and parameterize the User name and password fields so that qtp while running picks values for each iteration from data table.

Assume that following are the statements generated while login into Gmail:

Browser("Gmail").Page("Gmail").Webedit("Username").Set "user1"
Browser("Gmail").Page("Gmail").Webedit("password").Set "password1"

Browser("Gmail").Page("Gmail").Webbutton("Sign In").Click

Parameterizing through Expert View:

Just go to the script and change the script as follows:

Browser("Gmail").Page("Gmail").Webedit("Username").Set datatable("username", dtlocalsheet)

Browser("Gmail").Page("Gmail").Webedit("password").Set datatable("password", dtlocalsheet)


Browser("Gmail").Page("Gmail").Webbutton("Sign In").Click


In the data table local action sheet, add two columns with the name username and password and add multiple sets under that. While execution, for every iteration QTP picks one row data.



Parameterizing through Keyword view:

Second way of parameterizing is through Keyword view. Go to Keyword view and select the item (username value) to be parametrized by clicking in Value column. Now it displays a configure icon. Click on configure icon.



Value configuration dialog box gets raised. Now set parameter Radio button and also set the data table location as local sheet. Enter the desired name of column.




In the same way parameterize password field also. Now come to expert view and add additional sets of data in data table local sheet.

Parameterizing through Data-driver Wizard:

One more way of parameterizing the data in QTP is through Data driver wizard. Go to Tools-->Data driver



Quick test searches for all possible items that can be parameterized in your script and displays them in the form a list in Data driver dialog box.If any value is missed in list that you feel should also be parameterized, then just click on Add Value button.



Now add the value that is already present in the script which needs to be parameterized. QTP will not allow to add a value that is not there in the script.

The number that gets displayed under constant/parameterize column indicates the number of occurences of the same object in the script. i.e., assume that a object is occuring twice in the script and is not yet parameterized, then for that object 'constant column' value would be 2 and parameterize column will display '0'. And assume that there is a object that is occuring once in the script and is already parameterized, then value for that under Constant would be '0' and under Parameterize column would be '1'.

Now select a value to be parameterized and click on Parameterize button. Data driver wizard opens.



Data driver wizard- Select Paramaterization screen would be displayed with two options:

  • Step by Step parameterization
  • Parameterize all
The difference between these two can be clearly known when a object has multiple occurences in the script. For example, assume that an object has 3 occurences in the script, then selecting Step by Step parameterization will alllow user to parameterize each occurence individually and selecting Parameterize all will allow user to parameterize all the 3 occurences at once.

Step by Step Parameterization:

When Step by Step Parameterization option is selected and clicked on Next button, 'Parameterize the Selected Step' window gets displayed.



QTP gives a default name and location in the data table for the value that is about to be parameterized. Click on Parameter options icon to change the default name and location.



Enter required name and select Location in data table and click on Ok and click on finish.

Parameterize All

When Parameterize all option is selected in Data driver wizard, 'configure value' section present in the same window gets enabled.



Click on Parameter option icon to change the default values. After changing the default values click on Ok and finish.



Parameterizing through Object Repository:

Go to Object repository and select the object that needs to be parameterized and click on 'Configure Value' icon.



Value configuration options dialog box gets raised. Set the Parameter radio button. Select the location in data table and enter a customized name in the Name field and click on Ok button.


3 comments:

  1. Awesome blog. I got impressed really. Just can’t imagine your tech. Your notice point is very clear and can be short little more. I need the elaborated story of your mentioning.

    Java training in Chennai | Android training in chennai | IOS training in chennai

    ReplyDelete
  2. nice one...thanks...

    ReplyDelete