ARM
ARM

Reputation: 11

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

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 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.

Upvotes: 1

Views: 3272

Answers (2)

BlackGaff
BlackGaff

Reputation: 7707

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

Upvotes: 2

Vance
Vance

Reputation: 396

  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.

Upvotes: 0

Related Questions