需要帮助了解jmeter正则表达式提取器和结果树输出 [英] Need help understanding jmeter regular expression extractor and results tree output

查看:155
本文介绍了需要帮助了解jmeter正则表达式提取器和结果树输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个页面,该页面以以下格式返回一组目录ID:

I have a page that returns a set of catalog ids in the following format:

addCatentryId('445653', '23151', 'csb_RVI_10053');

我正在尝试将上述每个值分成一个数组以进行进一步评估.

I am trying to separate each of the above values into an array for further evaluation.

根据该论坛另一篇文章中的建议,建议采用两步法:

Based on suggestions in another post in this forum, a two step approach was recommended:

1)使用第一个正则表达式提取器从页面响应数据中检索以上数据段

1) Use the first regular expression extractor to retrieve the data segment above from the page response data

2)对第一个数据提取的结果执行后续的正则表达式提取器,以将字符串数据转换为可用值的数组.

2) Execute a follow-up Regular Expression extractor against the results of the first data extract to convert the string data into an array of usable values.

为此,我在JMeter脚本中设置了以下提取器:

To this end, I have setup the following extractors in my JMeter script:

提取器1: Jmeter正则表达式提取器1

提取器2: Jmeter正则表达式提取器2

执行上述操作时,我得到以下结果,我不确定该如何解释,但是似乎找到了catEntryIDString,但由于某种原因未将其送入第二个正则表达式过程:

When I execute the above, I get the following results, which I am not sure how to interpret, but it appears that the catEntryIDString is being found, but for some reason is not being fed to the second regular expression process:

JMeterVariables:
JMeterThread.last_sample_ok=true
JMeterThread.pack=org.apache.jmeter.threads.SamplePackage@41035d67
START.HMS=073225
START.MS=1479126745560
START.YMD=20161114
TESTSTART.MS=1479129860911
__jmeter.USER_TOKEN__=Place User Order 1-1
arrValItemId= <---- Why is this empty?
catEntryIDString=null <--- should this be null?
catEntryIDString_g=0
catEntryIDString_g0=addCatentryId('460734', '12220', 'csb_RVI_10053'); <-- data appears to be getting retrieved by 1st extractor

任何帮助将不胜感激,因为Google搜索不会找到有用的信息,并且JMeter的BlazeMeter帮助页面没有涉及太多细节(至少基于我对该站点的信息搜索).

Any help would be greatly appreciated, as Google Search turns up no useful information, and the BlazeMeter help pages for JMeter do not go into this much detail (at least based on my information searches of that site).

提前谢谢!

推荐答案

您不需要两个正则表达式提取器即可从单个响应中捕获多个值.我们可以使用模板通过使用()(即括号)指定多个组来捕获多个值.

you don't need two regular expression extractors to capture multiple values from single response. we can use Template to capture multiple values by specifying multiple groups using () i.e., parenthesis.

尝试以下正则表达式:

addCatentryId\('(.*?)', '(.*?)', '(.*?)'\);

以下为图片参考:

一旦将所有三个值捕获到称为AllValuesReference Name中(在示例图像中),那么我们可以按以下方式访问每个组/值:

Once you capture all three values into Reference Name called AllValues (in the example image), then we can access each group/value as follows:

第一组-AllValues_1_g1(产生445653) 第二组-AllValues_1_g2(产生23151) 第三组-AllValues_1_g3(产生csb_RVI_10053)

first group - AllValues_1_g1 (which yields 445653) second group - AllValues_1_g2 (which yields 23151) third group - AllValues_1_g3 (which yields csb_RVI_10053)

图片参考:

如果要在后续请求中引用任何捕获的值,则在JMeter中使用以下语法:

If you want to refer any captured valule in subsequent requests, we use the following syntax in JMeter:

$ {reference_name}

${reference_name}

例如:

${AllValues_1_g1}-使用445653值.

参考:

  1. https://stackoverflow.com/a/39547786/2575259

这篇关于需要帮助了解jmeter正则表达式提取器和结果树输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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