I'm looking for some advice on encoding in JMeter. I am currently working on a system that uses https and .aspx urls, and therefore need to encode all parameters within my post requests.As it stands i am copying and pasting web-forms from Fiddler to generate my test scripts. Is there a less labour intensive way to encode all my parameters of the web-form, because i am having to tick to encode each individual parameters.
问问题
1389 次
1 回答
0
- 很可能您正在做一些奇怪的事情,因为您使用 JMeter 的HTTP(S) 测试脚本记录器记录您的请求JMeter 应该自行填充请求参数,包括参数值编码(如果需要)。查看JMeter Proxy Step by Step了解如何记录测试场景的详细信息。
JMeter .jmx 脚本基本上是XML 文件,因此您应该能够在您喜欢的文本编辑器中打开 JMeter 脚本,找到以下行:
<boolProp name="HTTPArgument.always_encode">false</boolProp>
并将其替换为
<boolProp name="HTTPArgument.always_encode">true</boolProp>
您可以使用JSR223 PreProcessor和以下Groovy代码将未编码的参数替换为其编码的等效参数:
org.apache.jmeter.config.Arguments args = sampler.getArguments() sampler.getArguments().removeAllArguments() args.each { sampler.addEncodedArgument(it.getName(), it.getValue()) }
上面的代码将修改JSR223 PreProcessor 范围内的所有采样器,并用它们的编码等效项替换参数值。这种方法可能会占用大量资源,因此请明智地使用它,如果有可能,请考虑第 1 点和/或第 2 点中描述的替代方案。以防万一,请参阅Apache Groovy - 为什么以及如何使用它来熟悉 Groovy 脚本的概念在 JMeter 测试中。
于 2017-09-05T08:24:10.410 回答