How to parameterize http methods in Jmeter using CSV data config?

自作多情 提交于 2019-12-11 13:13:19

问题


How to parameterize http methods in Jmeter using CSV data config?

What I did: created an HTTP Request Sampler (method POST), but I need to create http request sampler from a csv file including method also.


回答1:


You can change the HTTP method using Beanshell Preprocessor.

Add a Beanshell preprocessor for your existing HTTP request. Your default HTTP method is POST.

Now lets change it to GET whenever the csv variable 'method' is 'GET'

if(vars.get("method").equalsIngoreCase("GET")){
    sampler.setMethod("GET");  //this will change current sampler's http method from POST to GET. 
}


来源:https://stackoverflow.com/questions/31729223/how-to-parameterize-http-methods-in-jmeter-using-csv-data-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!