How to extract the values from request input xml in jmeter

南笙酒味 提交于 2019-12-24 19:57:04

问题


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:


  1. Add JSR223 PostProcessor as a child of your request
  2. Put the following code into "Script" area:

    vars.put('request', sampler.getArguments().getArgument(0).getValue())
    
  3. Add XPath Extractor after the JSR223 PostProcessor
  4. Configure it as follows:

    • Apply to: JMeter Variable -> request
    • Reference Name: anything meaningful, i.e. refId
    • XPath Query: //*[starts-with(local-name(), 'refId')]

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!