How to parse response of sample1 to create new sample in JMeter

后端 未结 2 1325
渐次进展
渐次进展 2021-01-01 21:23

I use JMeter to do performance test of web server. My test case is as following:

step1: send file update request to server.
step2: server will return some fi         


        
2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-01 22:02

    This is how I extract some value from url and pass it further as variable so next requests will contain it.

    Here are some nice screenshot and wider description about making test in JMeter http://jmeter.apache.org/usermanual/build-web-test-plan.html

    Add the Thread Group and HTTP Requests

    When this HTTP Requests response with some data (in this example in URL) you want to extract it and us it after

    So lets go:

    1. Go to your first HTTP Request after which one you receive response with variable:

      Add -> Post Processor -> Regular Expression Extractor

      In this window set:

      Response Field To Check: URL

      Reference Name: MY-CUSTOM-VARIABLE-NAME

      define name of variable whatever you like

      Regular Expression: permanent.part.of.url.com/([a-zA-Z0-9]*)

      so expression ([a-zA-Z0-9]*) is responsible for getting all occurrences of alphabetic and numeric chars after meeting permanent url at start

      Template: $1$

      only one expression is extracted in our case and it need to be read

      Match No. (0 for Random): 1

      in this case there is only one match, but if more occur you can choose which one use

    2. Now put extracted value into next HTTP Request Path: some.other.url.com/${MY-CUSTOM-VARIABLE-NAME}

      remember that you read JMeter variables with this pattern ${}, so use ${MY-CUSTOM-VARIABLE-NAME} whenever you need this value

    Run your test and check what did you get in url of your request with MY-CUSTOM-VARIABLE-NAME Experiment with regexp to get desired output.

    Here is blogpost about this stuff: http://kenning.co.nz/development/extracting-variables-using-regular-expressions-in-jmeter/

    And always useful JMeter documentation: http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor

提交回复
热议问题