Jmeter postprocessor

1.JSON Extractor

  • Extractor Json postprocessor for use in the format of the HTTP request returns the Json for obtaining a value returned by Json. And save it as a variable for subsequent requests will be or calls such assertions.

  • Names Variable : variable name stored later with reference $ {Variable names}
  • Path Expressions JSON : the previous step through debugging json path expression
  • Numbers Match : matching digits (0 represents a random, 1 for the first, -1 for all)
  • Values the Default : The default value can not be found, usually set to NOT FOUND
  • Var concatenation Compute (suffix_ALL) : whether to count all values saved all upcoming matches to be known as "variable name _ALL", usage scenarios need to get multiple values are behind the need for the operation of this set of data

 

  • Json Path expression of use

JsonPath

description

$

Root

@

The current node

.or[]

Child node

..

Select all eligible node

*

All nodes

[]

Iterator mark, such as an array subscript

[,]

Support iterator do multiple choice

[start:end:step]

Array slice operator

?()

Support filtering

()

Support for expression evaluation

 

2. Regular Expressions

  • Reference name : variable name their own definition, the subsequent request will be a reference to the variable name, such as filling that: the JWT, the latter reference is $ {JWT}
  • Regular Expressions : Extract the contents of the regular expression, the equivalent of the correlation function loadrunner
    • "()" In square brackets is the need to extract, for you need to mention the contents enclosed in parentheses  
    • . "" Match any character except newline  
    • "*"     (贪婪)   重复零次或更多  
      • 例如"aaaaaaaa" 匹配字符串中所有的a  正则: "a*"   会出到所有的字符"a"
    • "+"    (懒惰)   重复一次或更多次 
      • 例如"aaaaaaaa" 匹配字符串中所有的a  正则: "a+"  会取到字符中所有的a字符,  "a+"与"a*"不同在于"+"至少是一次而"*" 可以是0次      
    • "?"    (占有)   重复零次或一次  
      • 例如"aaaaaaaa" 匹配字符串中的a 正则 : "a?" 只会匹配一次,也就是结果只是单个字符a    
    • "*?"   重复任意次,但尽可能少重复   
      •   例如 "acbacb"  正则  "a.*?b" 只会取到第一个"acb" 原本可以全部取到但加了限定符后,只会匹配尽可能少的字符 ,而"acbacb"最少字符的结果就是"acb"     
    • "+?"   重复1次或更多次,但尽可能少重复,与"*?" 一样,只是至少要重复1次  
    • 还有分组的情况,常用的就这两种,其它的可以再自行百度  
      • "(?=exp)"      匹配exp前面的位置    
      • "(?<=exp)"    匹配exp后面的位置    
  • 模板:用$$引用起来,如果在正则表达式中有多个正则表达式(多个括号括起来的),则可以是$2$,$3$等等,表示解析到的第几个值给actionId。例如:$1$表示匹配到的第一个值
  • 匹配数字:0代表随机取值,1代表所有值,此时提取结果是一个数组,其余正整数代表第几个匹配的内容提取出来。如果匹配数字选择的是1
  • 缺省值:正则匹配失败时,取的值
  • 想要知道正则表达式是否正确,可以在请求后加入调试取样器(右键-添加-取样器-调试取样器debug sampler)
  • 没有特殊的情况用(.*?)就可以解决所有问题

 

 

Guess you like

Origin www.cnblogs.com/Mr-ZY/p/11845188.html