在JMeter测试计划中为POST方法设置HTTP请求采样器 [英] Setting up HTTP Request Sampler for POST Method in JMeter Test Plan

查看:234
本文介绍了在JMeter测试计划中为POST方法设置HTTP请求采样器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序,其中所有页面/服务都使用基于中央身份验证服务(CAS)的安全性进行保护.我需要使用HTTP POST请求在页面上执行负载测试,但不知道如何为此具有通过CAS安全性访问权限的POST方法配置HTTP Request Sampler. 我可以获取故障单以从浏览器手动访问页面,如下所示:

I have a web application where all the pages/services are secured using Central Authentication Service (CAS) based security. I need to perform a load testing on a page using HTTP POST request but have no idea how to configure HTTP Request Sampler for this POST method having access through security of CAS. I can get the Ticket to get access to the page manually from the browser which is as follows:

https://<server>:<portX>/testweb-cas/oauth2.0/callbackAuthorize?ticket=ST-17-J5jknSbPrU1pQ5vFK0bL-testweb.au 

现在,我想为设置HTTP POST请求采样器:

Now I want to set up HTTP POST Request Sampler for :

http://<server>:<portY>/Xyz/pages/details.xhtml使用上方链接中的authorization.

我以前在JMeter中没有使用过HTTP Request POST采样器,也没有使用可用的解决方案真正获得所需的输出.

I haven't used HTTP Request POST sampler before in JMeter, and not really getting the desired output using the available solution.

推荐答案

最简单的方法:

使用HTTP测试脚本记录器,该记录器记录来自浏览器的流量并使用HTTP Sampler构建JMeter测试计划.

Use HTTP Test Script recorder, which records the traffic from the browser and build JMeter Test Plan using HTTP Sampler.

另一种方法是,将HTTP Samplers手动添加到Thread Group.从Method下拉列表中选择Post.提及请求Body data部分的正文.如果要向请求中添加标头(例如Authorization标头),请添加HTTP Header Manager.

Another way is, to manually add HTTP Samplers to the Thread Group. Select Post from Method drop down. Mention the body of the request Body data section. Add HTTP Header Manager if you want to add Headers to the request, like Authorization header.

注意:请勿通过访问浏览器手动获取Authorization值.记录导航,因此将为该请求添加HTTP Sampler.添加Regular Expression Extractor以从响应中检索授权值并将其存储在变量中,以便可以在POST请求中使用它.

Note: Don't take Authorization value manually by visiting the browser. Record the navigation, so HTTP Sampler will be added for that request. Add Regular Expression Extractor to retrieve Authorization value from the response and store it in a variable, so that you can use it in the POST request.

注意::添加HTTP Cookie Manager(如果在录制过程中尚未添加),以便JMeter自动处理基于Cookie的身份验证.

Note: Add HTTP Cookie Manager (if not already added during recording) so that JMeter automatically takes care of Cookie based authentication.

参考文献:

  1. HTTP采样器
  2. 测试脚本记录器
  3. 正则表达式提取器
  1. HTTP Sampler
  2. Test Script Recorder
  3. Regular Expression Extractor

这篇关于在JMeter测试计划中为POST方法设置HTTP请求采样器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆