如何在jmeter中提取动态元素的值

时间:2017-01-16 15:58:27

标签: jmeter

我在单个页面上有多个动态元素,元素包含我的HTML代码所遵循的多个数据

onclick="AddRemoveMemberDeal(event,'1494576','cd691c62-32b2-444d-ad6f-79a6104e4ee5','3997800330','Flaxseed Meal','Bobs Red Mill','$2.99','2.99','1/19/2017','85','Whole Ground','Shaw\'s','2','https://products.mygrocerydeals.com/nw/200/0/3/3/3997800330.jpg?deal=cd691c62-32b2-444d-ad6f-79a6104e4ee5&upc=3997800330&chain=194'); return false;"

我记录的脚本值是

{"IdMember":"1494576","DealId":"c2b20119-44f2-4839-83c8-5382afd48e04","UPC":"7430500116","Name":"Regular Apple Cider Vinegar","Brand":"Bragg","Custom_Price":"$5.49","Price":"5.49","Sale_End":"1/5/2017","Score":"80","Description":"null","ChainName":"Stop & Shop","CategoryId":"2","ImageURL":"https://products.mygrocerydeals.com/generic/baking-goods.jpg?deal=c2b20119-44f2-4839-83c8-5382afd48e04&upc=7430500116&chain=204"}

如何动态提取所有值?

1 个答案:

答案 0 :(得分:0)

您需要使用Regular Expression Extractor(后处理器)在HTTP响应中应用正则表达式并使用组检索值。

将Regex Extractor保留在HTTP Sampler下,以对应要应用regex的响应并检索数据。

Reference Name字段是保存值的变量。

参考文献:

  1. http://jmeter.apache.org/usermanual/regular_expressions.html
  2. https://guide.blazemeter.com/hc/en-us/articles/207421325-Using-RegEx-Regular-Expression-Extractor-with-JMeter
  3. Caprture multiple values in Single Regex Extractor