Jmeter在每个http请求之后清除cookie [英] Jmeter Clear cookies after each http request

查看:685
本文介绍了Jmeter在每个http请求之后清除cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在jmeter上下文中,是否有任何方法可以在同一线程组中的每个http请求之后清除cookie?

In jmeter context, is there any way to clear cookies after each http request within the same thread group?

推荐答案

为什么在这种情况下您完全需要HTTP Cookie Manager?只需将其删除,您将获得预期的行为.

Why in that case you need HTTP Cookie Manager at all? Just remove it and you'll get expected behaviour.

以防万一,您有某种奇怪的负面测试场景:

Just in case you have some form of weird negative test scenario:

  1. 添加 Beanshell侦听器
  1. Add a Beanshell Listener or Beanshell Assertion at the same level with all HTTP Request samplers
  2. Put the following code into "Script" area

import org.apache.jmeter.protocol.http.control.CookieManager;

CookieManager manager = ctx.getCurrentSampler().getProperty("HTTPSampler.cookie_manager").getObjectValue();
manager.clear();

请参阅以下参考资料:

  • JMeterContext class JavaDoc (referenced as ctx in the above script)
  • CookieManager class JavaDoc
  • How to Use BeanShell: JMeter's Favorite Built-in Component

这篇关于Jmeter在每个http请求之后清除cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆