0

I am new in JMeter.

I am using JMeter to test scenario in JSF application, the scenario to login the application and open crud page (issue_warning_create.jsf) to create record in database and it is successful with my browser but when I test the scenario with JMeter it fails with this exception:

javax.faces.application.ViewExpiredException: viewId:/secure/adt/fin/issue_warning_create.jsf could not be restored.

I noticed that JMeter use different session id than session id get from response. I tried to listen logout to terminate session and make new request with new session in JMeter but also give me the same exception. I add http cookie manager and xpath extractor to get view state as in images:

enter image description here

enter image description here

enter image description here

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please read [Under what circumstances may I add “urgent” or other similar phrases to my question, in order to obtain faster answers?](//meta.stackoverflow.com/q/326569) - the summary is that this is not an ideal way to address volunteers, and is probably counterproductive to obtaining answers. Please refrain from adding this to your questions. – halfer Nov 08 '17 at 09:50
  • I updated my answer following your additional details – UBIK LOAD PACK Nov 08 '17 at 11:24

2 Answers2

0
  • You must add a Cookie Manager

  • You must also correlate JSF View State using Regex Extractor:

Regex : input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="([^"]+)".*/

varName: jsfViewState

Template : $1$

You'll have then to use ${jsfViewState} wherever it is present.

See:

In your test, replace -1 in XPath Extractor by 1

Community
  • 1
  • 1
UBIK LOAD PACK
  • 33,980
  • 5
  • 71
  • 116
  • Thanks very much this fixed my problem – Mohammed Mostafa Nov 08 '17 at 14:53
  • Please UBIK LOAD PACK this page have some lists to select items and then submit to db,when I run scenario in jmetere with 5 users its ok but when I run it with 10 users give me java.lang.IndexOutOfBoundsException: Index: 0, Size: 0. why? – Mohammed Mostafa Nov 09 '17 at 11:31
0

JSESSIONID can operate in 2 modes:

  1. As a HTTP Cookie, in this case HTTP Cookie Manager will do the trick
  2. As a part of the URL. If your application appends JSESSIONID to the request URL you need to use HTTP URL Re-writing Modifier to automatically handle this value and amend your URLs accordingly.

With regards to Viewstate, your XPath Extractor seems to be correct, however in case of not very well-formed XHTML you might need to tick Use Tidy box. Double check your myViewState variable value using Debug Sampler and View Results Tree listener combination.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133