开发者

help in storing a value and calling a variable in jmeter request using regular extractor

开发者 https://www.devze.com 2023-03-01 09:41 出处:网络
my soap/xml response looks like below: <Account><Accountnumber>1234<Description>savings</Account><Account><Accountnumber>1235<Description>Savings1</Accoun

my soap/xml response looks like below:

<Account><Accountnumber>1234<Description>savings</Account><Account><Accountnumber>1235<Description>Savings1</Account>

I would like to store accountnumbers in a variable or array and would call it in another 开发者_Go百科soap xml request in jmeter for knowing their details. can somebody help me how i can store and how i can call that variable ? I am new to Jmeter.

Thanks in advance.


If the account numbers are static, you're better off using a .csv file, as mentioned by Vance because the CSV data reader has less overhead then regex.

However, if you want dynamic data, it's very easy to do.

  1. Download "regex coach" to help you write regular expressions. It's an amazing tool.
  2. Attach a "regular expression extractor" as a child to your SOAP/XML request
  3. Run the request once, to get the reponse
  4. Copy the response into regex coach (or whatever tool you use), and write your regex. It'll look something like this: (\d+?)\D (look for any digit after the text accountNumber and stop after a non-digit)
  5. Configure the rest of the regex. In this case, you'll want:

    • Apply to: Main Sample Only
    • Response filed to check: Main Body
    • Reference Name: VariableName
    • Regular Expression: See step 3
    • Match No: 1 (1st match) 0 (any match) or -1 (all matches, useful when doing "FOR EACH found" logic
    • Default Value: failed
  6. TO use your variable account number in other requests, simply use the reference name. In this example: ${VariableName}

Reference: http://jmeter.apache.org/usermanual/component_reference.html#Regular_Expression_Extractor


  1. You may save your data in a ".csv" file and Jmeter can read it easily through its csv data set config.
  2. Use ${your data variable} in your scripts.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号