Unable to set incremental variable in Jmeter

拥有回忆 提交于 2019-12-02 10:17:58
  1. Be aware that starting from JMeter version 3.1 it is recommended to use Groovy for any form of scripting to consider migrating to JSR223 PostProcessor

  2. Looking into repeating 'DayOfWeek':'xxx' pattern it seems you don't need to create 7 branches for each weekday, you can extract the current value using Regular Expressions and set or get and increment the relevant JMeter Variable

Example code would be something like:

def day = (prev.getResponseDataAsString() =~ "'DayOfWeek':'(\\w+)'")[0].get(1)
def value = (vars.get(day) ?: '0') as int
value++
vars.put(day, value as String)

See Apache Groovy - Why and How You Should Use It article for more information on using Groovy scripting in JMeter tests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!