Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

I'm facing an issue while running a recorded test scenario of an application login using a single user on JMeter.

I've used JMeter's proxy server to record all the requests of the login scenario. The proxy server records all the requests fine. When i play the recorded scenario, the login step gives response data that contains "Your session has expired". It seems that the JSF ViewState value is getting hard-coded when I record the requests due to which when the steps are played the new ViewState values generated from the server do not match.

I tried using solutions given in these links to handle ViewState values:

But still it doesn't work.
Am i missing something?
Or is it something other than the ViewState that's causing the recorded steps to fail?

Screenshots below:

screen #1 screen #1

screen #2 screen #2

screen #3 screen #3

share|improve this question
    
I used the procedure in your first link and it worked. –  mbonaci Jun 5 '12 at 8:24
    
it's not working. These are the steps i followed: 1. Recorded the steps using the proxy server. 2. Added a user-defined variable 'jsfViewState' to the Thread Group. 3. Added a RegEx Extractor to the Thread Group with reference name 'jsfViewState' and value as <input type="hidden" name="javax\.faces\.ViewState" id="javax\.faces\.ViewState" value="(.+?)" /> 4. Modified the javax.faces.ViewState Request Parameter for the login steps as ${jsfViewState} and any further requests that are using the ViewState parameter. 5. Played the steps. –  Abhijeet Vaikar Jun 5 '12 at 9:23
    
Are these the steps you followed too? –  Abhijeet Vaikar Jun 5 '12 at 9:29
add comment

1 Answer

up vote 1 down vote accepted

1) You have to extract viewState value BEFORE the usage.
I.e. if you send viewState value along with login-request so you have to extract this value from response to PREVIOUS request.

Thread Group
    HTTP Request 01 : /login GET
        XPath Extractor : extract jsfViewState
    HTTP Request 02 : /login POST (send previously extracted jsfViewState as param)
        XPath Extractor : extract jsfViewState for next request
    . . .

2) You are extracting viewState to the variable ${Var_ViewState} (screen #1) but refer it as ${ViewState} (screen #3).
Be careful.

3) In your XPath Extractor (screen #1) you have to check Use Tidy (tolerant parser) checkbox on the element's control panel - since you are using xpath against html, not xml (presume that some kind of warning should also appear in jmeter.login this case).

XPath query itself looks good, although string() is redundant.

4) Add HTTP Cookie Manager to your test-plan to handle session variables (jsessionid).

share|improve this answer
    
Sorry about refering to the Var_ViewState variable as ${ViewState}. I did realize that after posting my query here. But correcting the reference still didn't help me. I haven't tried the steps 1,3,4 you mentioned. Will check that and revert back. Thanks a lot for your help. –  Abhijeet Vaikar Jun 5 '12 at 9:34
    
I enabled the Use Tidy (tolerant parser) checkbox. And also used the HTTP Cookie Manager. But I have just added a HTTP Cookie Manager to the Thread Group. Do i have to make any changes / add any cookies in the Cookie Manager? It's still not working. –  Abhijeet Vaikar Jun 5 '12 at 10:58
    
@ Abhijeet, HOW it's not working? Is jsfViewState extracted? What's in jmeter.log? Simply add HTTP Cookie Manager at the top level (Test Plan), that's should be enough. Have you encoded jsfViewState value upon sending along with request ("Encoded" checkbox, wiki.apache.org/myfaces/PerformanceTestingWithJMeter -> Some Notes)? –  Alies Belik Jun 5 '12 at 11:05
    
jmeter.log: pastebin.com/yAij3w5H Yes, i've added HTTP Cookie Manager at the top level (Test Plan). And i've set the encoded checkbox for jsfViewState to checked. I have referenced jsfViewState as ${jsfViewState} in the parameters (after the login request) of any requests that contain ViewState in their headers. I'm very much confused as to what's exactly not working. I'm completely a JMeter newbie, so please bear with me. –  Abhijeet Vaikar Jun 5 '12 at 11:42
    
Okay. Once more. See point #1 in answer above - I've added schema to use. To send jsfViewState value along with login POST request you need somehow extract it (ViewState) before - e.g. send login GET first. You will extracted jsfViewState value on each request to use it in the NEXT one - but not in the same. –  Alies Belik Jun 5 '12 at 11:58
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.