The recent lemon class students found flowers, asked a question, is the use of JMeter interface testing, how to extract the head of the Jsessionid and then pass to the next request, continue to complete the current user's request.
In fact, there are three ways to solve this problem:
1) Extract Jsessionid from the response data and click on the link to view https://www.cnblogs.com/liulinghua90/p/5320290.html
2) If the response data does not return Jsessionid, then you can keep the cookie, click the link to view: https://www.cnblogs.com/liulinghua90/p/9257552.html
3) If the response header has this jsessionid, we can add a cookie to solve this problem, today this blog, we focus on the third method.
First, before the test preparation
1. Test Address:
Login: http://XXXX:8080/futureloan/mvc/api/member/login Recharge: Http://XXXX:8080/futureloan/mvc/api/member/recharge
2. Parameter extraction:
Parameters of Login: mobilephone, pwd recharge parameters: mobilephone, amount
3. Pre-test scenario:
1: After logging in, a Jessionid response header is generated as the result of the login response. 2: The recharge request must be sent to the server with Jesssionid to request success.
4: Selection Tool:Jmeter
Second, start testing
1: Open jmeter---> Add thread Group---> Add HTTP request---> Fill in the login request data as follows:
2: Open jmeter---> Add thread Group---> Add HTTP request---> Fill in the Recharge request data as follows:
3. Run the thread group, check the results of the login and the result of the recharge, and find that the login succeeded as follows:
The top-up is unsuccessful, prompt as follows:
4. Check the request header for the response data that is logged in JMeter, as follows:
Third, using regular expression to extract the jsessionid of the response head
1: Add a regular expression to the HTTP request to log in, extracting the jsessionid from the head as follows:
The contents of the Jsessionid returned by the original login are as follows:
set-cookie:jsessionid=639a471fbecf4e2a20947a0150a2b887; path=/Futureloanset-cookie:rememberme=deleteme; Path=/futureloan; max-age=0; Expires=mon, 02-jul-2018 02:14:05 GMT
Regular expressions we write the following format:
Set-cookie:jsessionid= (. *); Path=/futureloan
So we can match to Jsessionid!
2: Add a cookie manager to the Recharge interface:
3: Save well, start the request again and get the following result:
4: Also see the top-up request with the original cookie
Four: summary
What if I have multiple requests? You can add cookie! to each request in turn Or add a total cookie for all requests to use.
JMeter How to extract the Jsessionid of the response head