Parameterization In QTP

Parameterization is the process of substituting values for dynamic parameters from a CSV(Comma separated values) file or from the Database.

For example, when testing a web application that contains a login page, "parameterization” lets you use a different login name and password for each virtual user (dynamic substitution of values). There’s no need for each User Scenario to contain a separate script that performs the task of logging in. Similarly, you can parameterize the cookies and other headers passed in the request header such as Scheme, Proxy-Connection, etc. You can also parameterize the parameters passed with the URL string.

In this example suite, the user name and password are dynamically substituted from the csv file. For this purpose, a data.csv file is created and placed under /projects/WebPerformanceDemo/usersrc folder. The csv file contains 100 usernames and password starting from emp1 to emp100. Hundred logins should be populated in the application's database. This is done using the following steps:

Click the 'Edit' link under HTTP Parameters adjacent to a recorded transaction in the load test screen. This will invoke the Parameterization screen. The recorded URLs will be loaded in the left-side panel.

Select the URL used for logging into the application.

Choose the Parameters tab. The parameters for the URL will be shown in a table.

In the table, look for the parameter with the name 'userpass'. From the Fetch Data From column corresponding to the row, click the arrow in the button and select the parameterize type as 'Dataset'. Configure the dataset to fetch the values from CSV and click the Apply button.

The Value column will display the configured dataset value.

Similarly, select the parameter 'username' and configure the data source for the same.

The above steps will use the same script with 100 different usernames and password to login and simulate the load of 100 virtual users.

How many ways we can parameterize data in QTP?

There are four types of parameters:
Test, action or component parameters enable you to use values passed from your test or component, or values from other actions in your test.

Data Table parameters enable you to create a data-driven test (or action) that runs several times using the data you supply. In each repetition, or iteration, QuickTest uses a different value from the Data Table.

Environment variable parameters enable you to use variable values from other sources during the run session. These may be values you supply, or values that QuickTest generates for you based on conditions and options you choose.

There are three types of environment variables: 
 User-defined internal. Variables that you define within the test. They are saved with the test and accessible only 
within the test in which they were defined.
 User-defined external. Variables that you predefined in the active external environment variables file. These variables 
are read-only in this context. 
 Built-in. Variables that represent information about the test and the computer on which the test is run, such as 
Test path and Operating system. These variables are accessible from all tests, and are designated as read-only

Random number parameters enable you to insert random numbers as values in your test or component. For example, to check how your application handles small and large ticket orders, you can have QuickTest generate a random number and insert it in a number of tickets edit field.

0 comments:

Post a Comment