Follow

Data Correlation and Parameterization

HTTP requests often carry data that need to be used or changed during the execution of a test.

To edit HTTP requests, go to the Session Table and click on the session that contains the requests. 

On the table of requests click on the link for the URL you want to edit. 

You will see two or three pull down menus, depending on the request type (See the image below):

  • HEADERS
  • REQUEST DATA
  • SESSION VARIABLES

 

Correlation1.png

All three areas have editable fields.

HEADERS display all the fields that were imported during recording. In addition it is possible to add extra fields, by clicking on the "+" button at the bottom of the list of headers.

Correlation2.png

For example one might need to add an extra header field that is used in test environments only. 

Correlation3.png

All fields can take as values strings, meta-characters and variables. A variable can also contain data uploaded via a file. The data in the file have to be in CSV format, and can be replayed sequentially (default) or randomly (by selecting Yes in the Randomize Selection field)

REQUEST DATA is an option available with POST/PUT requests only.

The Quick Reference chart below provides the information for generating random data. 

NOTE: variables can also generate random data, by uploading a file.

Ex: The POST request enters physical addresses of users. If it needs to generate random addresses, very likely the values, such as state or city need to be correct. By uploading a list of all the states of the US this information can be randomized. 

Correlation4.png

 

 

SESSION VARIABLES can be of different types and can be used to grab and share values during the test execution.

NOTE: Do not use underscore or other special characters in the variable name. 

Variables are global to the session (and sequential Multi-session), and can also be used in the URL path. For example, if the test environment might change name, one could define an environment variable (in this case called "newdomain") in the first URL, and use it for each of the requests, like in the image below.

Correlation6.png

The "newdomain" variable was defined in the first request, as shown here:

Correlation7.png

In the image above, you see one type of variables. Static variables are used to define a value that does not change during the execution, like the domain name used in the URL path. 

There is a second type that is used to grab dynamic values, via a regular expression. These variables are based on a regular expression as defined in http://regexr.com and a brief description is also available in the request page, by clicking on "Show instructions for session variables" link (see image below).

 

Correlation8.png 

All the variables can be used by any subsequent request, and can be also overwritten. 

It is possible to:

- take some data coming from the body of a request its response

- take data from the request URL

- take data from an uploaded file

- take data from the Header fields in the request or its response

Once the data is saved in the variables, it can be used by other requests

In this way one can:

- modify global environment values

- assign specific values to fields of a request

- combine more than one variable in a request

- pass values from one request to others

The example below shows how some of the data taken from the request above can be used in another request. This is for example the case of a login. In the image above we define the authenticity token (authToken) variable as a regular expression, that takes the value from the body of the request, every time it is called. The POST request below uses it in the REQUEST DATA area.

Correlation9.png

 

0 Comments

Please sign in to leave a comment.
Powered by Zendesk