[英]jmeter extract regular expression not get correct result
This is my html 这是我的HTML
<input name="__RequestVerificationToken" type="hidden" value="A9y6Ndf7Q2XP2Yz6zhaVChoIvpQGUrZRTvu9D_HnHnUcFBVInerxCjU4vpOXQYVhFwnzl-zAzkvtto7BLAVVr">
I want to extract value in jmeter Regular Expression Extractor. 我想在jmeter正则表达式提取器中提取值。
This is my regx window but when i post it i will not get expected token it is something like this __RequestVerificationToken=%24%7Bauth_token%7D
. 这是我的regx窗口,但是当我发布它时,我不会得到预期的令牌,它就像这样
__RequestVerificationToken=%24%7Bauth_token%7D
。
Try using $1$
as a Template, it should resolve your issue. 尝试使用
$1$
作为模板,它应该可以解决您的问题。
Looking into your request I can see that you're sending %24%7Bauth_token%7D
which being decoded looks like ${auth_token}
so you use case is not correct. 查看您的请求,我可以看到您正在发送
%24%7Bauth_token%7D
,该解码的内容看起来像${auth_token}
因此您的用例不正确。
You need 2 requests: 您需要2个请求:
auth_token
variable. auth_token
变量。 auth_token
variable. auth_token
变量。 See Using Regular Expressions in JMeter guide for more details. 有关更多详细信息,请参见《 JMeter指南》中的“ 使用正则表达式” 。
By the way, you can use combination of Debug Sampler and View Results Tree listener to see if there are any matches. 顺便说一句,您可以结合使用Debug Sampler和View Results Tree侦听器来查看是否存在任何匹配项。 It should be more convenient wrt groups and variables.
wrt组和变量应该更方便。
In general, it isn't recommended to use Regular Expressions to parse HTML. 通常, 不建议使用正则表达式来解析HTML。 I would suggest to use XPath Extractor instead.
我建议改用XPath Extractor 。 Relevant XPath expression will look like:
相关的XPath表达式将如下所示:
//input[@name='__RequestVerificationToken']/@value
Few things to notice: 几件事要注意:
Use Tidy
box in XPath Extractor Use Tidy
框。 We need to set the following Regular Expression Extractor values to extract the auth token values 我们需要设置以下正则表达式提取器值以提取auth令牌值
Reference Name : Auth_Token
Regular Expression : <input\sname="__RequestVerificationToken"\stype="hidden"\svalue="(.+)">
Template : $1$
Match No : 1
Default values : NOT FOUND TOKENS
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.