如何在JMeter中设置cookie通常通过Javascript设置? [英] How to set cookie in JMeter that is usually set via Javascript?
本文介绍了如何在JMeter中设置cookie通常通过Javascript设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在测试一个web应用程序。
在主页的导航菜单中,当点击一个节点时,将调用一个javascript函数。我查找这个函数,页面将重定向到目标页面之前将设置 document.cookie =current_moduleId = xxxx; path = /
。
解决方案
如何在JMeter中为每个请求设置cookie?
>
在BeanShell预处理器中,输入:
import org.apache.jmeter.protocol。 http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie(toto,titi,localhost,/,false,0);
manager.add(cookie);请注意,使用JSR223 PreProcessor + Groovy + Caching将会更好地表现
< bI am testing a web application.
In the navigation menu of the main page, when a node is clicked, a javascript function will be called. I look up this function, the page will set document.cookie="current_moduleId=xxxx;path=/"
before redirect to the target page.
So how can I set cookie in JMeter for every request?
解决方案 Create the following pan:
In BeanShell pre processor, put :
import org.apache.jmeter.protocol.http.control.CookieManager;
import org.apache.jmeter.protocol.http.control.Cookie;
CookieManager manager = sampler.getCookieManager();
Cookie cookie = new Cookie("toto","titi","localhost","/",false,0);
manager.add(cookie);
Note that using JSR223 PreProcessor + Groovy + Caching will be better for performances
这篇关于如何在JMeter中设置cookie通常通过Javascript设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文