Jmeter无法使用正则表达式提取器正确提取值 [英] Jmeter is not extracting correctly the value with the reg ex extractor

查看:690
本文介绍了Jmeter无法使用正则表达式提取器正确提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jmeter无法使用正则表达式正确提取值.
当我在带有以下html的regex教练中使用此regex (NAME="token" \s value="([^"]+?)")时,一切正常,但是当将带有regex extrator的reg添加到请求中时,即使输出的是相同的html,他也找不到值.

Jmeter is not extracting correctly the value with the regex.
When I play with this regex (NAME="token" \s value="([^"]+?)") in regex coach with the following html everything work fine but when adding the reg with a regex extrator to the request he doesn't found the value even if it's the same html in output.

<HTML>
<script type="text/javascript">
    function dostuff(no, applicationID)
    {
        submitAction('APPS_NAME' , 'noSelected=' + no + '&applicationID=' + applicationID);
    }
</script>

<FORM NAME="baseForm" ACTION="" METHOD="POST">
    <input type="hidden" NAME="token" value="fc95985af8aa5143a7b1d4fda6759a74" >

<div id="loader" align="center">
        <div>
            <strong style="color: #003366;">Loading...</strong>
        </div>
        <img src="images/initial-loader.gif" align="top"/>
    </div>

<BODY ONLOAD="dostuff('69489','test');">

</FORM>
</HTML>  

从正则表达式提取器中

Reference Name: token
Regular Expression: (NAME="token" \s value="([^"]+?)")
Template: $1$
Match No.: 1
Default value: wrong-token

上一条代码的POST之后的请求正在返回:

The request following my the POST of the previous code is returning:

POST data:
token=wrong-token

在树查看器中的下一个请求中

.

in the next request in the tree viewer.

但是,当我在代理中检查真实请求时,令牌就在那里.

But when I check a the real request in a proxy the token is there.

注意:我尝试了不带括号的正则表达式,但也不起作用.

Note: I tried the regex without the bracket and doesn't worked either.

有人知道这里出了什么问题吗?
为什么jmeter用正则表达式Extrator找不到我的令牌?

Do anybody have a idea whats wrong here?
Why jmeter can't find my token with the regex extrator?

推荐答案

您的正则表达式将查找文本NAME="token",后跟一个空格,然后是一个空格,制表符或换行符,然后是一个空格,然后是文本value=",后跟一个或多个非引号字符,再跟另一个".

Your regex looks for the text NAME="token", followed by a space, followed by a space, tab or newline, followed by a space, followed by the text value=", followed by one or more non-quote characters, followed by another ".

如果在查找的字符串中没有找到它(并且您的文本示例不匹配),则失败.

If it doesn't find that in the string it's looking at (and your text sample doesn't match), it fails.

您真正想做什么?看起来您正在用正则表达式解析HTML.这不是一个好主意.

What are you really trying to do? It looks like you're parsing HTML with regex. Not a good idea.

这篇关于Jmeter无法使用正则表达式提取器正确提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆