Setting up HTTP Request Sampler for POST Method in JMeter Test Plan

微笑、不失礼 提交于 2019-12-12 21:25:39

问题


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 

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

http://<server>:<portY>/Xyz/pages/details.xhtml using authorization from above link.

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


回答1:


Easiest way:

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

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.

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.

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

References:

  1. HTTP Sampler
  2. Test Script Recorder
  3. Regular Expression Extractor


来源:https://stackoverflow.com/questions/41818798/setting-up-http-request-sampler-for-post-method-in-jmeter-test-plan

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