I have a problem. I am using Regular Expression Extractor in Jmeter. I have two regex.
我有个问题。我在Jmeter中使用正则表达式提取器。我有两个正则表达式。
I can get the value from this.
我可以从中获得价值。
Reference Name: as_fid_addtobasket
Regular Expression: <input type="hidden" name="as_fid" value="(.+?)" />
Template: $1$
But i can't get the value from this one.
但我无法从这一点获得价值。
> Reference Name: DynamicTempOrderProductGuid
>
> Regular Expression: <input data-val="true" data-val-required="The
> TempOrderProductGuid field is required."
> id="OrderProducts_1__TempOrderProductGuid"
> name="OrderProducts[1].TempOrderProductGuid" type="hidden"
> value="(.+?)" />
>
> Template: $1$
> >
Here is my result. The second one doesn't get the value. Where is the thing i missed?
这是我的结果。第二个没有得到价值。我错过了哪里?
POST data: OrderProducts.index=1&OrderProducts%5B1%5D.TempOrderProductGuid=%24%7BDynamicTempOrderProductGuid%7D&OrderProducts%5B1%5D.Count=1&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.NameRec=Test+ama%C3%A7l%C4%B1d%C4%B1r.+L%C3%BCtfen+dikkate+almay%C4%B1n%C4%B1z&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.PhoneRec=05352233285&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.OSSendingReason=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.OSReceiverAddressType=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.CompanyNameRec=&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.AddressLineRec=Test+ama%C3%A7l%C4%B1d%C4%B1r.+L%C3%BCtfen+dikkate+almay%C4%B1n%C4%B1z&OrderProducts%5B1%5D.ProductCode=se213&OrderProducts%5B1%5D.TempOrderProductGuid=%24%7Btokentoken%7D&totalProducts=1&as_fid=efWZ0i4RGLmC2nBWk%2FA1
POST数据:OrderProducts.index = 1&OrderProducts%5B1%5D.TempOrderProductGuid =%24%7BDynamicTempOrderProductGuid%7D&OrderProducts%5B1%5D.Count = 1&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.NameRec = Test + ama%C3%A7l%C4% B1D%C4%B1R。+ L%C3%BCtfen + dikkate +爱尔美%C4%B1n的%C4%B1z&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.PhoneRec = 05352233285&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.OSSendingReason =&OrderProducts%5B1 %5D.ReceiverModel.OrderReceiver.OSReceiverAddressType =&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.CompanyNameRec =&OrderProducts%5B1%5D.ReceiverModel.OrderReceiver.AddressLineRec =测试+ AMA%C3%A7l%C4%B1D%C4%B1R。+ L&C3%BCtfen + dikkate +爱尔美%C4%B1n的%C4%B1z&OrderProducts%5B1%5D.ProductCode = se213&OrderProducts%5B1%5D.TempOrderProductGuid =%24%7Btokentoken%7D&totalProducts = 1&as_fid = efWZ0i4RGLmC2nBWk%2FA1
3 个解决方案
#1
2
I would recommend using XPath Extractor instead as regular expressions are pretty dependent on layout, attributes order, spaces, etc. and can be a real headache to develop and test for non-experienced used. Especially multi-line ones.
我建议使用XPath Extractor,因为正则表达式非常依赖于布局,属性顺序,空格等,并且对于没有经验的用户来说,开发和测试可能是一个非常令人头痛的问题。特别是多线的。
XPath expression for extracting value from as_fid
input will look like:
用于从as_fid输入中提取值的XPath表达式如下所示:
//input[@id='OrderProducts_1__TempOrderProductGuid']/@value
Some clues:
- If you're using JMeter 2.11 you'll be able to test your XPath expressions right in View Results Tree Listener
- You may need to check "Use Tidy" box in XPath Extractor if your HTML isn't XHTML compliant
- Check XPath Tutorial for language reference.
如果您正在使用JMeter 2.11,您将能够在View Results Tree Listener中测试您的XPath表达式
如果您的HTML不符合XHTML,则可能需要在XPath Extractor中选中“使用整洁”框
检查XPath教程以获取语言参考。
#2
0
Try this simpler regex for your second case:
在第二种情况下尝试使用这个更简单的正则表达式:
<input.+?value="(.+?)"\s*/>
Demo
#3
0
You can update the regex as the followings to get the valid DynamicTempOrderProductGuid
您可以将regex更新为以下内容以获取有效的DynamicTempOrderProductGuid
Reference Name: DynamicTempOrderProductGuid
Regular Expression: name="(.+)"\stype="hidden"value="(.+)"
Template: $2$
#1
2
I would recommend using XPath Extractor instead as regular expressions are pretty dependent on layout, attributes order, spaces, etc. and can be a real headache to develop and test for non-experienced used. Especially multi-line ones.
我建议使用XPath Extractor,因为正则表达式非常依赖于布局,属性顺序,空格等,并且对于没有经验的用户来说,开发和测试可能是一个非常令人头痛的问题。特别是多线的。
XPath expression for extracting value from as_fid
input will look like:
用于从as_fid输入中提取值的XPath表达式如下所示:
//input[@id='OrderProducts_1__TempOrderProductGuid']/@value
Some clues:
- If you're using JMeter 2.11 you'll be able to test your XPath expressions right in View Results Tree Listener
- You may need to check "Use Tidy" box in XPath Extractor if your HTML isn't XHTML compliant
- Check XPath Tutorial for language reference.
如果您正在使用JMeter 2.11,您将能够在View Results Tree Listener中测试您的XPath表达式
如果您的HTML不符合XHTML,则可能需要在XPath Extractor中选中“使用整洁”框
检查XPath教程以获取语言参考。
#2
0
Try this simpler regex for your second case:
在第二种情况下尝试使用这个更简单的正则表达式:
<input.+?value="(.+?)"\s*/>
Demo
#3
0
You can update the regex as the followings to get the valid DynamicTempOrderProductGuid
您可以将regex更新为以下内容以获取有效的DynamicTempOrderProductGuid
Reference Name: DynamicTempOrderProductGuid
Regular Expression: name="(.+)"\stype="hidden"value="(.+)"
Template: $2$