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 开发者_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.
- Download "regex coach" to help you write regular expressions. It's an amazing tool.
- Attach a "regular expression extractor" as a child to your SOAP/XML request
- Run the request once, to get the reponse
- 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)
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
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
- You may save your data in a ".csv" file and Jmeter can read it easily through its csv data set config.
- Use ${your data variable} in your scripts.
精彩评论