在jmeter中,在具有多个同名标签的xml响应中,我想验证如果标签onlineFulfilmentFlag的值为Y,则productId不应为空。如果上述条件失败,我想要打印失败消息"无效的产品ID" 。我也附上了回复。这段代码包含1个优惠的描述,但这个数字可以在0-10之间变化。
enter code here<offers>
<number xsi:nil="true"/>
<number>
<amrit>S</amrit>
<interestedFlag>Y</interestedFlag>
<msgid>145983</msgid>
<msisdn xsi:nil="true"/>
<offerIndex>1</offerIndex>
<msgtext>Rs115=225 </msgtext>
<onlineFulfilmentFlag>Y</onlineFulfilmentFlag>
<orderId xsi:nil="true"/>
<otherSearchInfo>
<number>
<key>START_DATE</key>
<value>2016-09-16 11:28:46.921455</value>
</number>
<number>
<key>END_DATE</key>
<value>2017-08-03 00:00:00.0</value>
</number>
<number>
<key>OFFER_CATEGORY</key>
<value>Others</value>
</number>
</otherSearchInfo>
<price>115</price>
<productId>ACT3G</productId>
<shortDesc>115=225Loc+STD M,28D</shortDesc>
<subscriptionStatus>P</subscriptionStatus>
</number>
<number>
<amrit>O</amrit>
<interestedFlag>Y</interestedFlag>
<msgid>143429</msgid>
<msisdn xsi:nil="true"/>
<msgid>2803708</msgid>
<offerIndex>2</offerIndex>
<msgtext>Rs306=Rs306 Full</msgtext>
<onlineFulfilmentFlag>Y</onlineFulfilmentFlag>
<orderId xsi:nil="true"/>
<otherSearchInfo>
<number>
<key>START_DATE</key>
<value>2016-09-16 11:28:46.921455</value>
</number>
<number>
<key>END_DATE</key>
<value>2017-08-03 00:00:00.0</value>
</number>
<number>
<key>OFFER_CATEGORY</key>
<value>Combo</value>
</number>
</otherSearchInfo>
<price>306</price>
<productId>ACT3G</productId>
<shortDesc>Rs306=306TT(Ultd Val)</shortDesc>
<subscriptionStatus>P</subscriptionStatus>
</number>
<number>
<amrit>O</amrit>
<interestedFlag>Y</interestedFlag>
<msgid>145022</msgid>
<msisdn xsi:nil="true"/>
<msgid>2800482</msgid>
<msgtext>Rs110=Rs110 Full</msgtext>
<onlineFulfilmentFlag>Y</onlineFulfilmentFlag>
<orderId xsi:nil="true"/>
<otherSearchInfo>
<number>
<key>START_DATE</key>
<value>2016-09-16 11:28:46.921455</value>
</number>
<number>
<key>END_DATE</key>
<value>2017-08-03 00:00:00.0</value>
</number>
<number>
<key>OFFER_CATEGORY</key>
<value>Others</value>
</number>
</otherSearchInfo>
<price>110</price>
<productId>ACT3G</productId>
<shortDesc>Rs110=Rs110 FTT, ULTD</shortDesc>
<subscriptionStatus>P</subscriptionStatus>
</number>
答案 0 :(得分:0)
像//number/onlineFulfilmentFlag='Y' and string-length(//number/productId) > 0
这样的东西应该可以解决问题。
您可以将上述表达式(或根据您的要求修改)放入XPath Assertion,如果productId
字段长度为零(或者不存在),则采样器将自动获取失败。
参考文献: