PS:所有函数助手都会有Name of variable in which to store the result (optional),该字段是jiang这个字段非必填
${__base64Decode}:对base64字符串进行解码
- ${__base64Decode(Base64 string to be decoded,Name of variable in which to store the result (optional))}
- Base64 string to be decoded:需要解码的base64变量(字符串)
- ${__base64Decode(QWxsZW4gaXMgdG9vIEFsbGVuLg==,)}的调用结果是base64=Allen is too Allen.
${__base64Encode}:对字符串进行base64编码
- ${__base64Encode(Base64 string to be encoded,Name of variable in which to store the result (optional))}
- Base64 string to be encoded:需要编码的字符串
- Name of variable in which to store the result (optional):保存编码结果的变量,非必填
- ${__base64Encode(234234uiukjlskldfsd23242,)}的调用结果是base64encode=c29uIG9mIGJpdGNo
${__BeanShell}:执行传递的beanshell脚本
- ${__BeanShell(Expression to,Name of variable in which to store the result (optional))}
- Expression to :一个BeanShell脚本(不是文件名),如果是.sh,.bat脚本,需要jmeter.bat同目录
- Name of variable in which to store the result (optional):存结果的变量,
- ${__BeanShell(1234*459,)}的调用结果是beanshells=566406
${__changeCase()}:字母大小写
- ${__changeCase(String to modify,Change case mode UPPER(default),LOWER,CAPITALIZE,Name of variable in which to store the result (optional))}
- String to modify:需要转换的英文字符
- Change case mode UPPER(default),LOWER,CAPITALIZE:UPPER为所有字母转为大写,LOWER为所有字母转为小写,CAPITALIZE开头字母大写,非必填,默认转换成大写
- ${__changeCase(abc,,)的调用结果:changecase1=ABC
- ${__changeCase(abc,UPPER,)}的调用结果:changecase2=ABC
- ${__changeCase(ABC,LOWER,)}的调用结果:changecase3=abc
- ${__changeCase(abc,CAPITALIZE,)的调用结果:changecase4=Abc
${__char()}:提供十进制和十六进制数字翻译成unicode字符串,参考下面的__unescape()函数
- ${__char(Unicode character number (decimal or 0xhex))}
- Unicode character number (decimal or 0xhex):十进制或十六进制的数字
- ${__char(0xD,0xA)}的调用结果为char=(没结果。。。。)
${__counter}:每次调用计数器函数都会产生一个新值,从1开始每次加1。计数器既可以被配置成针对每个虚拟用户是独立的,也可以被配置成所有虚拟用户公用的。
- ${__counter(TRUE, for each user to have own counter, FALSE for a global counter,Name of variable in which to store the result (optional))}
- TRUE, for each user to have own counter, FALSE for a global counter
- Name of variable in which to store the result (optional)
${__CSVRead}:函数__CSVRead会从CSV文件读取一个字符串(请注意与StringFromFile 的区别),通常用于CSV参数化
- ${__CSVRead(CSV file to get values from | *alias,Column number of CSV file | next | *alias)}
- CSV file to get values from | *alias:csv文件路径 或者 *alias
- Column number of CSV file | next | *alias:从文件的哪一列读起,”next”为走到文件的走一行。 *ALIAS为打开一个文件,并给它分配一个别名
- ${__CSVRead(E:\资料\jmeter性能进阶\作业\了解如何定义定义变量和调用函数\param.txt,0)的执行结果是csvreader=number
- -
${__dateTimeConvert}:日期格式函数,根据格式要求展示日期
- ${__dateTimeConvert(Date to be formatted,Source format of date,Target format of date,Name of variable in which to store the result (optional))}
- Date to be formatted:日期,需要转格式的日期
- Source format of date:原来日期的格式
- Target format of date:需要转成的格式
- ${__dateTimeConvert(20180810,MMddyyyy,dd/MM/yyyy,)}调用结果:date=18/08/0811
${__digest}:加密数据
- ${__digest(Digest algorithm,String to be hashed,Salt to be used for hashing (optional),Upper case result, defaults to false (optional,Name of variable in which to store the result (optional))}
- Digest algorithmL:加密算法,包括MD2、MD5、SHA-1、SHA-224、SHA-256、SHA-384、SHA-512
- String to be hashed:需要加密的字符串
- Salt to be used for hashing (optional):额外加密内容,可以是随机数或随机字符串
- Upper case result:将加密结果换成大写字符串
- ${__digest(SHA-512,son of bitch,,,)}调试结果:digest1=ffb7a7fd72608a7154c291ebc09e4a2af5e7c838b8d97b26a3b78dfb479db8d34e764dad0d716a8834079358212edee11961091476cd29ba2c3679fe66b60cb6
- ${__digest(SHA-384,down,123,,)调试结果:digest2=b63aa358ec5e89e4ce13517c5487dc4a88651719d89d2a0bc0dbf78cf0c4148c0fcb34dfece15089fbd08734bc0f024d
${__escapeHtml}:用于转义字符串中的字符(使用HTML实体)
- ${__escapeHtml(String to escape)}
- String to escape:转义字符串
- ${__escapeHtml(“bread” & “butter”)}调用结果:escape= “&”quot;bread”&”quot;” &”amp;” &”quot;butter"”;”
${__escapeOroRegexpChars}:正则表达式转义
- ${__escapeOroRegexpChars(Value to escape from ORO Regexp meta chars,Name of variable in which to store the result (optional))}
- Value to escape from ORO Regexp meta chars:正则表达式
- ${__escapeOroRegexpChars([^”].+?,)}调用结果:[\^\”].+\?
${__escapeXml}:用于转义字符串中的字符(使用XML实体)
- ${__escapeXml(String to escape)}
- String to escape:转义字符串
- ${__escapeXml(“bread” & ‘butter’)}调用结果:”&”quot;bread”&”quot; ‘&’amp; ‘&’apos;butter&’apos;
${__eval}:计算一个参数表达式的值
- ${__eval()}
- Text containing variable and function references:参数表达式
- 给定参数值:Table=mytable Column=username Username=dennis
SQL=select columnfrom c o l u m n f r o m {table} where userid=’${username}’
则{__eval( {__eval( {SQL})}得到的值为select username from mytable where uername=’dennis
${__evalVar()}与 __eval雷同,唯一不同的是evalVar()括号里的参数是保存在一个值里,也就是说 query是直接包含参数值
${__FileToString}:读取文档内容
- ${__FileToString(Enter path (absolute or relative) to file,File encoding if not the platform default (opt),Name of variable in which to store the result (optional))}
- Enter path (absolute or relative) to file:文件地址,可相对路径也可绝对路径
- File encoding if not the platform default (opt):如果文件的编码不是系统默认编码,就需要使用该参数标明,非必填
- ${__FileToString(E:\资料\jmeter性能进阶\作业\了解如何定义定义变量和调用函数\param.txt,,)}调试结果:number
found
${__groovy(,)}:运行groovy脚本
执行方法见beanshell
${__intSum}:求和
- ${__intSum(First int to add.,Second int to add - further ints can be summed by adding further arguments.,Name of variable in which to store the result (optional))}
- First int to add.:第一个参数
- Second int to add - further ints can be summed by adding further arguments.:第二、第三。。。个参数
- ${__intSum(1,2,3,4,5,)}调用结果:15
${__isPropDefined}:是否有属性定义
- ${__isPropDefined(Name of property)}
- Name of property:属性名称
- ${__isPropDefined(HM.AM)}:如果有属性名为HM.AM,返回TRUE,否则返回false
${__isVarDefined()}:是否有该值
- ${__isVarDefined(Name of property)}:有则返回true,无则返回false
${__javaScript}:执行JavaScript脚本
- ${__javaScript(JavaScript expression to evaluate,Name of variable in which to store the result (optional))}
- JavaScript expression to evaluate:JavaScript脚本
{__log}:记录日志,日志输出
-
{__log}:记录日志,日志输出 -
{__log(String to be logged (and returned),Log level (default INFO) or OUT or ERR,Throwable text (optional),Additional comment (optional)}
- String to be logged (and returned):输出的字段
- Log level (default INFO) or OUT or ERR:日志的等级,默认INFO,有输出,错误日志
- Throwable text (optional):记录日常
- ${__log(123123123,,,)}=123123123
${__logn(,,)}:也是记录日志,输出日志,只是会少个Throwable text参数
${__lowercase}:转为小写字符
- ${__lowercase(BDFDFSRT,)} = bdfdfsrt
${__Random}:生成随机数,每次生成一次
- ${__Random(1,100,)} = 45
${__RandomDate}:按时间格式返回随机时间
- ${__RandomDate(dd MM yyyy,,08 07 2050,,)} = 28 11 2038
__RandomString :返回随机字符串
- ${__RandomString(10,abcdefgh1234567890,)} = be6311398b
__regexFunction:正则表达式函数可以使用正则表达式(用户提供的)来解析前面的服务器响应(或者是某个变量值),函数会返回一个有模板的字符串,其中携带有可变的值。
__regexFunction还可以被用来保存值,以便供后续使用。
- 第1个参数是用于解析服务器响应数据的正则表达式。它会找到所有匹配项。如果测试人员希望将表达式中的某部分应用在模板字符串中,一定记得为其加上圆括号。例如,。这样就会将链接的值存放到第一个匹配组合中(这里只有一个匹配组合)。又如,。在这个例子中,链接的name作为第一个匹配组合,链接的value会作为第二个匹配组合。这些组合可以用在测试人员的模板字符串中。
- 这是一个模板字符串,函数会动态填写字符串的部分内容。要在字符串中引用正则表达式捕获的匹配组合,请使用语法:[groupnumber]。例如1或者 2,模板可以是任何字符串。
- 其他参数非必填。
__setProperty:设置属性值,jmeter的变量