I'm using JMeter to do some load tests on my JSF application and I'm having trouble passing the ViewState along the pages. The ViewState variable doesn't get extracted at all or it doesn't get passed along the pages.
I've recorded my test steps with a proxy server and this is what it looks like:
I've added the Regex extractor in the first GET request. Tested the regex and it is correct.
In every POST request I replace the hardwired View IDs with my variable.
And what I get when I send the request is the following:
The POST parameters are incorrect, as it sends the name of the variable.
POST data:
loginForm%3ArequestToken=&loginForm%3Ausername=heller&loginForm%3Apassword=%21QAYxsw2%A7EDC&loginForm%3AloginButton=Anmelden&com.sun.faces.VIEW=%24%7BjsfViewState%7D&loginForm=loginForm
Could you tell what I'm doing wrong here?
Thanks!
With JMeter you should not plan to test a single method. JMeter is supposed to be used for functional testing or Loap&Performance testing. For that you only "simulate a normal user" and then repeat that simulation... The easiest way to do that is to use JMeter's transparent recording proxy (see JMeter doc).
Extract ViewState value from the response using a suitable JMeter Post-Processor, for normal web pages the best option is CSS Selector Extractor. This way you will get the ViewState from the response and save it into a JMeter Variable Request 2 - replace recorded hard-coded ViewState value with the JMeter Variable from the previous step.
The regex is not much different: I’ve just used a different name and a negative occurrence number. This will tell JMeter to extract all available occurrences. Note that occurrence 0 tells JMeter to extract one occurrence randomly amongst all that are available.
Let’s have some fun! JMeter Regular Expression Extractor is designed to extract content from server responses using Regular Expressions. It is part of JMeter’s Post Processors family. As you can see, there are many other useful post-processors as well like: JSR223: run groovy / javascript / java scripts on the sample result. How do we use it?
The ViewState parameter is an encoded value (Base64 I believe?) and may contain values that would be inappropriate if passed in a GET request through the url. URL parameters are typically encoded so that special values (Eg. space -> %20) can be represented and decoded when the request reaches the server.
The issue here is that the following request is a POST meaning that the parameters do not need to be URL encoded.
com.sun.faces.VIEW=%24%7BjsfViewState%7D&loginForm=loginForm
The above shows that JMeter or some other process is URL encoding the ViewState in the request which is incorrect. The value of the ViewState should simply be sent as is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With