Software testing skills, JMeter stress testing tutorial, get post request data in x-www-form-urlencoded format (24)

I. Introduction

Some of the parameters of the post request are in the json format, and some are in the x-www-form-urlencoded format. When we talked about the signature, the post request is in the json format.

This article continues to talk about how to obtain the request body in the x-www-form-urlencoded format

Two, x-www-form-urlencoded

Add the Content-Type type to x-www-form-urlencoded in the request header

Define user variables, account and password post request parameters to fill in key-value pairs

3. BeanShell  preprocessor

add-preprocessor-beanshell-preprocessor

Use the getArgumentsAsMap() method to get the request body of the key-value pair

import org.apache.jmeter.config.Arguments;
import org.apache.jmeter.config.Argument;
import org.json.JSONObject;
import org.json.JSONArray;
import org.apache.commons.codec.digest.DigestUtils;    //导入md5加密的包

Arguments arguments =  sampler.getArguments();
Map reqMap = arguments.getArgumentsAsMap();
log.info("------------------------body------------------");
for (String key : reqMap.keySet()) {
    log.info("key: " + key + ",value: " + reqMap.get(key));
}
log.info(reqMap.get("username"))

4. Check the running results

The number of results can be viewed in the request header parameter type

Request body data: username=test&password=123456


              [The following is the most complete software test engineer learning knowledge architecture system diagram in 2023 that I compiled]


1. From entry to mastery of Python programming

2. Interface automation project actual combat

3. Actual Combat of Web Automation Project


4. Actual Combat of App Automation Project

5. Resume of first-tier manufacturers


6. Test and develop DevOps system

7. Commonly used automated testing tools


Eight, JMeter performance test

9. Summary (little surprise at the end)

life is long so add oil. Every effort will not be let down, as long as you persevere, there will be rewards in the end. Cherish your time and pursue your dreams. Don't forget the original intention, forge ahead. Your future is in your hands!

Life is short, time is precious, we cannot predict what will happen in the future, but we can grasp the present moment. Cherish every day and work hard to make yourself stronger and better. Firm belief, persistent pursuit, success will eventually belong to you!

Only by constantly challenging yourself can you constantly surpass yourself. Persist in pursuing your dreams and move forward bravely, and you will find that the process of struggle is so beautiful and worthwhile. Believe in yourself, you can do it!

Guess you like

Origin blog.csdn.net/NHB456789/article/details/131555883