Configure dynamic parameters
A framework dynamic parameter is made up of the following:
- General information:
- Name: Parameter name. This is for information purposes and must be unique.
- Framework: Name of the framework with which the parameter is associated.
- Extraction: Defines how the dynamic value is extracted from the server response.
- Extract from the Body or Headers in the server HTTP response. Selects from which part of the response the parameter dynamic value is extracted.
- XPath expression (optional): The XPath expression option allows restricting the content extraction to one subsection within the response. XPath can only be used for HTML or XML (HTML, XML, SOAP, GWT, AMF, RTMP, Oracle Forms, Java Serialization and Siebel) -type responses.
- Regular expression: Where the response contains text that corresponds to the regular expression definition, that text is extracted. The regular expression is applied to the response header or body or to the result of the XPath expression where specified.
- Value template: The template used to assemble the value. This is an arbitrary string with specific elements that refer to the groups within the regular expression (a group is a dynamic part of the regular expression contained within parentheses): $0$ refers to the entire text matching the expression, $1$ refers to group n°1, $2$ refers to group n°2, and so on.
- Set the default value: Set a default value for the variable when the definition is not matched in the server response.
- Throw an assertion error: Treat as an assertion failure when the definition is not matched in the server response, thus causing the request to be error-flagged in the test results.
- Use custom decoder: Check this option if you want to apply a customized decoder on the extracted value.
- Edit decoder: Click this button to provide the decoding logic in JavaScript that you want to be used to decode the extracted value.
- Replacement: Specifies where and how the dynamic value is injected into the request sent to the server.
- Parameter name: Check the box if the parameter name is dynamic and contains all or part of the extracted dynamic value.
- Parameter value: Check the box if the parameter value is dynamic and contains all or part of the extracted dynamic value. Where the parameter name is specified, only the parameters with that name are examined and, if necessary, modified.
- Path: Use this option if the path contains the dynamic value.
- Header value: Use this option when the values of the headers contains the dynamic value.
- Text content: Use this option if the request text content contains all or part of the dynamic value.
- Part of the text: All occurrences of the dynamic value are replaced in the text request.
- Regular expression: Only replace the values that match the specified regular expression.
XPath expression (optional): The XPath expression is used to restrict the replacement to a subsection of the request. The XPath expression can only be used for HTML or XML -type requests (HTML, XML, SOAP, GWT, AMF, RTMP, Oracle Forms, Java Serialization and Siebel).
Regular expression: The expression corresponding to the string that contains or equals the extracted dynamic value.
Groups: The groups in the regular expression applied to the text content that equal the extracted dynamic value, separated by commas.
Dynamic parameter configuration example
The dynamic parameter is called id and you can assume the dynamic value extracted is 12345. The text request will be <p>The dynamic value is 12345, and not 12345.</p>.
The regular expression used for replacement will be (The dynamic value is) (\d+), (and not) (\d+).
If Groups equals 2, 4, then the request will be changed to <p>The dynamic value is ${id}, and not ${id}.</p>.
If Groups equals 2, then the request will be changed to <p>The dynamic value is ${id}, and not 12345.</p>.
Advanced usage
When certain versions of GWT are used, it can be useful to generate multiple dynamic parameters.
In this advanced usage of dynamic parameters, dollar signs are used to perform the following steps:
- The Regular expression specified in the Extraction section is run.
- Replacements are done in the Regular expression field of the Replacement section using dollar signs.
- Replacements are done in the Name field using dollar signs.
- The dynamic parameter search is done as usual.
- To generate multiple dynamic parameters
- Add an extra group using parentheses in the Regular expression field of the Extraction section.
- Use dollar signs in the Regular expression field of the Replacement section to retrieve the values of the extra group added in the Regular expression field of the Extraction section.
- Specify a name for the parameter using dollar signs in the Name field.
- Click OK.
Home