Testing applications built with Seam Java framework is possible with JMeter like any other web applications, though there are some nuances to take into account.
If you analyze the response data with a listener you may notice ViewState parameter that is returned as part of a response to the first GET request (that opens the page):
But this is a dynamic parameter, so we cannot just pass j_id5 value every time, it will eventually change and our test will be broken. 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
Then we need to add Regular Expression Extractor as a child to the first request.
Add -> Post Processors -> Regular Expression Extractor
Regular expression would be: id=\"javax.faces.ViewState\" value=\"(.+?)\"
It will extract the value of javax.faces.ViewState parameter from the response data and assign it to VIEWSTATE variable.
Then we use this variable in the second request:
Now your JMeter tests can successfully cover applications built with Seam framework.
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. Black-box testing doesn't require us to know how Seam framework works, right? Okay, in this case we only need to know how it affects our tests.
As testers we need to make sure that ViewState parameter in the POST request has the same value as returned by a 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 a listener you may notice ViewState parameter that is returned as part of a response to the first GET request (that opens the page):
... <input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id5" /> ...To make it work properly you should pass javax.faces.ViewState parameter value in the second request, and the value must be the same, j_id5 in our case.
But this is a dynamic parameter, so we cannot just pass j_id5 value every time, it will eventually change and our test will be broken. 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
Then we need to add Regular Expression Extractor as a child to the first request.
Add -> Post Processors -> Regular Expression Extractor
Regular expression would be: id=\"javax.faces.ViewState\" value=\"(.+?)\"
It will extract the value of javax.faces.ViewState parameter from the response data and assign it to VIEWSTATE variable.
Then we use this variable in the second request:
Now your JMeter tests can successfully cover applications built with Seam framework.