正则表达式提取器中的模板和匹配数字是什么意思。
匹配数字就是用来选择是哪一次匹配。
模板是用来指定${变量名}时的输出格式的。
从jmeter上摘抄的文字,
Suppose you want to match the following portion of a web-page:
name="file.name" value="readme.txt" and you want to extract both
file.name and readme.txt.
A suitable reqular expression would be:
name="([^"]+)" value="([^"]+)"
This would create 2 groups, which could be used in the JMeter Regular Expression Extractor template as $1$ and $2$.
The JMeter Regex Extractor saves the values of the groups in additional variables.
For example, assume:
- Reference Name: MYREF
- Regex: name="(.+?)" value="(.+?)"
- Template: $1$$2$
| Do not enclose the regular expression in / / |
The following variables would be set:
- MYREF: file.namereadme.txt
- MYREF_g0: name="file.name" value="readme.txt"
- MYREF_g1: file.name
- MYREF_g2: readme.txt
另外,可以写一些简单的函数对结果进行检查。
JMeter functions are special values that can populate fields of any Sampler or otherelement in a test tree. A function call looks like this:
${__functionName(var1,var2,var3)}
Where "__functionName" matches the name of a function.
Parentheses surround the parameters sent to the function, for example ${__time(YMD)}The actual parameters vary from function to function. Functions that require no parameters can leave off the parentheses, for example ${__threadNum}.
If a function parameter contains a comma, then be sure to escape this with "\", otherwise JMeter will treat it as a parameter delimiter.For example:
${__time(EEE\, d MMM yyyy)}
Variables are referenced as follows:
${VARIABLE}
在测试restful api的时候,需要加一个http头信息管理器,其中添加参数,content-type:application/json,这样可以支持发送json格式的内容给服务器。
本文详细解析了JMeter中正则表达式提取器的使用方法,包括模板和匹配数字的概念,并通过实例说明如何提取所需数据,同时介绍了如何利用JMeter函数对结果进行验证。
2475

被折叠的 条评论
为什么被折叠?



