无法移动到变量完全响应 - Groovy Jmeter
Can not move to variable full response - Groovy Jmeter
我在Jmeter中遇到了无法解决的问题。
我想创建一个发送请求并获得响应的测试。
响应是 url 编码。
所以首先我需要将响应放在一个变量中,而不是 url 对其进行解码。
1. 我创建了正则表达式并将响应放在变量名 "full_response" 中,它按预期保存,如您在结果中所见。
2. 我创建了一个 groovy 采样器步骤,只是想传递 "full_response" 并打印它,知道它通过了 OK。
并且它不会仅打印 3 个字母的所有响应。 (我想是因为响应是 URL ENCODE)。
有人可以建议如何将此变量传递给 groovy 脚本吗?而不是打印出来?
目的是 url 解码结果并对其进行断言!!
我如何将结果放入 groovy 采样器的 "reponse_before_decode" 变量中,而不是 url 对其进行解码。
在调试采样器中,我 没有 看到我在 groovy 采样器中创建的 response_before_decode 变量
是因为响应带有特殊字符吗?我不能把它作为一个整体传递>? (请参阅带有正则表达式的完整响应变量中的响应)
问候
def reponse_before_decode = args[0] as String;
def reponse_before_decode_2 = args[0];
System.out.println ("re" + '$full_response');
System.out.println ("full" + reponse_before_decode_2);
System.out.println ("full" + reponse_before_decode);
- 切勿在 Groovy 脚本中引用 JMeter 变量或函数,如
${full_response}
,请改用 vars.get('full_response')
,因为它可能与 GStringTemplates 冲突
您不需要正则表达式提取器中间步骤,您可以从 JSR223 采样器访问以前的采样器结果,例如:
def reponse_before_decode = ctx.getPreviousResult().getResponseDataAsString()
其中 ctx
代表 JMeterContext class 实例
- 最后 JMeter 附带 __urlDecode() function which you can use to decode
x-www-form-urlencoded
strings. See Apache JMeter Functions - An Introduction 以熟悉 JMeter 函数概念。
我在Jmeter中遇到了无法解决的问题。 我想创建一个发送请求并获得响应的测试。 响应是 url 编码。 所以首先我需要将响应放在一个变量中,而不是 url 对其进行解码。 1. 我创建了正则表达式并将响应放在变量名 "full_response" 中,它按预期保存,如您在结果中所见。 2. 我创建了一个 groovy 采样器步骤,只是想传递 "full_response" 并打印它,知道它通过了 OK。 并且它不会仅打印 3 个字母的所有响应。 (我想是因为响应是 URL ENCODE)。 有人可以建议如何将此变量传递给 groovy 脚本吗?而不是打印出来? 目的是 url 解码结果并对其进行断言!! 我如何将结果放入 groovy 采样器的 "reponse_before_decode" 变量中,而不是 url 对其进行解码。 在调试采样器中,我 没有 看到我在 groovy 采样器中创建的 response_before_decode 变量 是因为响应带有特殊字符吗?我不能把它作为一个整体传递>? (请参阅带有正则表达式的完整响应变量中的响应) 问候
def reponse_before_decode = args[0] as String;
def reponse_before_decode_2 = args[0];
System.out.println ("re" + '$full_response');
System.out.println ("full" + reponse_before_decode_2);
System.out.println ("full" + reponse_before_decode);
- 切勿在 Groovy 脚本中引用 JMeter 变量或函数,如
${full_response}
,请改用vars.get('full_response')
,因为它可能与 GStringTemplates 冲突
您不需要正则表达式提取器中间步骤,您可以从 JSR223 采样器访问以前的采样器结果,例如:
def reponse_before_decode = ctx.getPreviousResult().getResponseDataAsString()
其中
ctx
代表 JMeterContext class 实例- 最后 JMeter 附带 __urlDecode() function which you can use to decode
x-www-form-urlencoded
strings. See Apache JMeter Functions - An Introduction 以熟悉 JMeter 函数概念。