One of them is ViewState parameter. This parameter is dynamic and it means that we cannot just leave it hardcoded in our JMeter script because it will be broken the next time you try to execute it. Why this happens? Let's dig a little deeper. Though for pure black-box testing we don't need to know how Seam framework works, right? Ok, then we only need to know how it affects our tests.
As testers we need to know one thing: if we pass ViewState parameter in the POST request, it should be the same as returned by the previous GET request.
For example you have two subsequent requests:
- GET http://x.x.x.x:8080/some_page.seam
- POST http://x.x.x.x:8080/some_page.seam
If you analyze the response data with listener you may notice ViewState parameter that is returned as response to the first request where we open the page:
<input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id5" />
To work it properly you must pass javax.faces.ViewState parameter in the second request and the value must be the same: j_id5.
But remember? This is a dynamic parameter, so we cannot just pass j_id5 value always, it will change and the test will break. We need to parse it from the first request, store in a variable and then use it in the second request instead of hardcoded value. Let's see how we can do it.
At first we need to create JMeter user variable, let's call it VIEWSTATE.
Add -> Config Element -> User Defined Variables
Add -> Post Processors -> Regular Expression Extractor
It will extract the value of javax.faces.ViewState parameter from the response data and assign it to VIEWSTATE variable.
We use this variable in the second request: