问题
I wanted to extract the value of refid1 and refid2 tags form the input xml in Http request. refID1 and refid2 values are generated at runtime using random number function .
please find below attached screenshot for the problem :
Request tab snapshot from Jmeter.
Thanks in advance!
回答1:
Since you're generating the data, I suppose you have access to the XML request data.
So in this case, you can make those 2 fields variables extracted from CSV using CSV Data Set config.
If you're generating them using JMeter __Random function, then you can use this syntax:
${__Random(0,10, MYVAR)}
And then use ${MYVAR}
回答2:
- Add JSR223 PostProcessor as a child of your request
Put the following code into "Script" area:
vars.put('request', sampler.getArguments().getArgument(0).getValue())- Add XPath Extractor after the JSR223 PostProcessor
Configure it as follows:
- Apply to: JMeter Variable ->
request - Reference Name: anything meaningful, i.e.
refId XPath Query:
//*[starts-with(local-name(), 'refId')]
- Apply to: JMeter Variable ->
- You will be able to access your "refId" values as
${refId_1}and${refId_2}where required.
来源:https://stackoverflow.com/questions/47069882/how-to-extract-the-values-from-request-input-xml-in-jmeter