Interview Questions

How do I make parameters dynamic, reacting to the unique server responses of each test run?

Apache JMeter FAQ


(Continued from previous question...)

How do I make parameters dynamic, reacting to the unique server responses of each test run?

You can use the Regular Expression Post Processor to extract a value from a response, and then reuse this response in another request. Looking at the previous question in this FAQ, you could extract the product id from the result and use it in the following request:

1. Load Test Plan created in previous FAQ question

2. Add Post Processor > Regular Expression Extractor to thread Group with following values:

1. Reference Name: product
2. Regular Expression: product_id=(\w*-\w*-\w*)
3. Template: $1$
4. Match No.: 0 (Setting this parameter to 0 returns a random match) 3. Copy the HTTP Request we created in the previous question and paste to the thread group after the previous HTTP Request
4. Change the following values:
1. Path: /estore/control/product
2. Add Parameter and set name to product_id, value to ${product}
5. Save Test Plan
6.

Run > Start

When you view the results in the View Results Tree, you can see the ${product} value was replaced with the value extracted by the regular expression.

(Continued on next question...)

Other Interview Questions