JMeter JSR223后处理器GET COOKIE [英] JMeter JSR223 PostProcessor GET COOKIE
问题描述
我在JMeter中找到的有关cookie的每个链接都是基于cookie管理器的.但是不幸的是,如果更改路径,JMeter会丢失cookie,并且我无法更改JMeter属性以使用有关此问题的解决方案,因此在请求后,我必须使用JSR223 PostProcessor的设置变量.
Every link I've found about cookies in JMeter is based on cookie manager. But unfortunately, JMeter losts cookies if path is changed, and I can't change JMeter properties to use solutions about that, so I have to use setting variable by JSR223 PostProcessor after request.
但是我找不到有关此的任何信息-每个链接都是关于使用HTTP Cookie管理器的.
But I can't find any information about that - every link is about using HTTP Cookie Manager.
请在没有Cookie管理器的情况下提供解决方案的帮助.
Please help with solution WITHOUT Cookie Manager.
推荐答案
blazemeter has a good examples about creating cookies in JSR223
import org.apache.jmeter.protocol.http.control.*
//Get cookie manager
CookieManager cm = sampler.getCookieManager()
//Set cookie currency to EUR
cm.addFile("C:/work/jmeter-scripts-samples/cookie.txt")
CookieManager.addFile(String cookieFile)方法将在cookieFile参数(此示例中为cookie.txt)中定义的cookie添加到cookie管理器.
The method CookieManager.addFile(String cookieFile) adds the cookie defined in the cookieFile parameter (cookie.txt in this example) to the cookie manager.
我们将通过在PreProcessor脚本中添加以下行来创建cookie:
We will create a cookie by adding the following line to the PreProcessor script:
Cookie c = new Cookie("sampleCookie", "sample", "opencart.abstracta.us", "/", false, 1557578515)
这篇关于JMeter JSR223后处理器GET COOKIE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!