我对Jmeter(3.1)有点新意,但我有一个很大的任务要完成它。
我已经配置jmeter来达到100万个http请求,一切都很好
我进入日志文件的xml响应是使用转义字符,但我想要的日志文件需要用unescape字符保存,
<httpSample ng="41" na="41"> <responseData class="java.lang.String"><?xml version="1.0" encoding="UTF-8"?><methodResponse><params><param><value><struct><member><name>avail ableServerCapabilities</name><value><array><data><value><i4>536871488</i4></value><value><i4>8</i4></value></data></array></v alue></member><member><name>negotiatedCapabilities</name><value><array><data><value><i4>0</i4></value></data></array></value> </member><member><name>originTransactionID</name><value><string>1606456</string></value></member><member><name>responseCode</name><value& gt;<i4>139</i4></value></member></struct></value></param></params></methodResponse></responseData> </httpSample>
我想要的是
<methodResponse><params><param><value><struct><member><name>availableServerCapabilities</name><value><array><data><value><i4>536871488</i4></value><value><i4>8</i4></value></data></array></value></member><member><name>currency1</name><value><string>TZS</string></value></member><member><name>dedicatedAccountDeleteInformation</name><value><array><data><value><struct><member><name>dedicatedAccountID</name><value><i4>1402</i4></value></member><member><name>dedicatedAccountUnitType</name><value><i4>6</i4></value></member><member><name>dedicatedAccountValue1</name><value><string>5368535040</string></value></member><member><name>expiryDate</name><value><dateTime.iso8601>99991231T12:00:00+0000</dateTime.iso8601></value></member><member><name>startDate</name><value><dateTime.iso8601>00000101T12:00:00+0000</dateTime.iso8601></value></member></struct></value></data></array></value></member><member><name>negotiatedCapabilities</name><value><array><data><value><i4>0</i4></value></data></array></value></member><member><name>originTransactionID</name><value><string>1606684</string></value></member><member><name>responseCode</name><value><i4>0</i4></value></member></struct></value></param></params></methodResponse>
请帮忙!
顺便说一句,如何将originTransactionID和responseCode保存到csv文件中。请点亮它
答案 0 :(得分:1)
您无法“按原样”保存XML响应,因为以下5个字符需要在XML文件中进行转义:
"
'
<
>
&
因此,如果您只需保存originTransactionID
和responseCode
,则可以执行以下步骤:
按如下方式配置:
originTransactionID
//member/name[text()='originTransactionID']/../value/string/text()
添加另一个XPath Extractor并将其配置为:
responseCode
//member/name[text()='responseCode']/../value/i4/text()
将下一行添加到 user.properties 文件(位于JMeter安装的“bin”文件夹中)
jmeter.save.saveservice.output_format=csv
sample_variables=originTransactionID,responseCode
originTransactionID
和responseCode
个值参考文献: