脚本实现了,根据url判断该接口执行是否beanshell
import org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy
// 获取当前HTTP请求采样器(需判断类型避免非HTTP请求报错)
def sampler = ctx.getCurrentSampler()
if (sampler instanceof HTTPSamplerProxy) {
HTTPSamplerProxy httpSampler = (HTTPSamplerProxy) sampler;
// 获取完整URL或路径
String currentUrl = httpSampler.getUrl().toString();
String currentPath = httpSampler.getPath();// 定义需要跳过的URL规则(精确/模糊匹配)
String skipUrl = "/ucs/uia/scan/qrcode";
String skipPathKeyword = "/ucs/uia/scan/qrcode";// 匹配则退出脚本
if (currentUrl.equals(skipUrl) || currentPath.contains(skipPathKeyword)) {
log.info("=====终止前置脚本执行,后续逻辑不运行=======")
return; // 终止脚本执行,后续逻辑不运行
}
}
778

被折叠的 条评论
为什么被折叠?



