admin管理员组文章数量:1353278
I 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?
I 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?
Share Improve this question edited Dec 4, 2012 at 13:32 Andrei Botalov 21.1k11 gold badges90 silver badges124 bronze badges asked Dec 3, 2012 at 9:29 BugdailyBugdaily 1771 gold badge2 silver badges10 bronze badges 1- See jmeter.512774.n5.nabble./…. I wasn't able to get it to work – Andrei Botalov Commented Dec 4, 2012 at 10:13
2 Answers
Reset to default 7Create 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
For people who e across this in future, I had to use 0 or -1 for the expiry time of the cookie:
Cookie cookie = new Cookie("toto","titi","localhost","/",false,-1);
Any positive integers seemed to not set the cookie
本文标签: How to set cookie in JMeter that is usually set via JavascriptStack Overflow
版权声明:本文标题:How to set cookie in JMeter that is usually set via Javascript? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743901926a2558831.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论