Bean shell脚本检查响应A或B是否存在于jmeter中的响应文本中

Bean shell scripting to check if response A or B is present in response text in jmeter

本文关键字:响应 存在 jmeter 文本 是否 脚本 shell 检查 Bean      更新时间:2023-09-26

如何使用beanshell脚本断言验证响应A或B是否存在于jmeter中的响应文本中

Beanshell断言提供以下预定义变量:

  • ResponseData -字节数组,包含父采样器响应
  • Failure -布尔值,指示断言(以及范围内的采样器)是否成功
  • FailureMessage -一个字符串,可用于提供自定义错误消息

示例代码检查响应是否包含A,如果不包含-采样器失败。

String response = new String(ResponseData);
Failure = !response.contains("A");
FailureMessage = "Response didn't contain A"; 

更多信息:如何在三个简单步骤中使用JMeter断言