JMeter How to keep cookies so that all requests can use the same cookie, eliminating the extraction of jsessionid

Source: Internet
Author: User

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, today this blog, we focus on this method.

3) If the response header has this jsessionid, we can add a cookie to solve this problem, click the link can be viewed: https://www.cnblogs.com/liulinghua90/p/9257548.html

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, add cookies and keep cookies

1: Add a cookie manager below the thread group, as follows:

2: Save well, start the request again and get the following result:

3: Also see the top-up request with the original cookie

Four: summary

The key to solving this problem is: 1) to know what the role of cookie session Jessionid is

2) How to extract these key information and keep

3) Learn to use regular expressions

JMeter How to keep cookies so that all requests can use the same cookie, eliminating the extraction of jsessionid

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.