修改 JMeter 中的 cookie 以在值周围包含花括号 [英] Modify a cookie in JMeter to include curly braces around the value

查看:19
本文介绍了修改 JMeter 中的 cookie 以在值周围包含花括号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 JSR223 后处理器,其中捕获的 c_QUID 值用花括号括起来并用于 cookie.例如,如果 c_QUID 是 5575-9878-4848-8897,那么我需要将 cookie 设置为 {5575-9878-4848-8897}.我可以在下面的脚本中修改什么来做到这一点?截至目前,它没有添加花括号.

I have the following JSR223 PostProcessor where the captured c_QUID value is to be surrounded by curly braces and used in a cookie. For example if c_QUID is 5575-9878-4848-8897, then I need to set the cookie as {5575-9878-4848-8897}. What can I modify in the below script to do that? As of now it does not add the curly braces.

import org.apache.jmeter.protocol.http.control.*

//Get cookie manager
CookieManager cm = sampler.getCookieManager()
log.info("XXXXXXXXXX QUID " + vars.get("c_QUID"));
Cookie c = new Cookie("QUID", vars.get("c_QUID"), "stage.randomtesting.com", "/", true, 1557578515)
cm.add(c);

推荐答案

使用字符串连接值:

new Cookie("QUID", "{" + vars.get("c_QUID") + "}",

这篇关于修改 JMeter 中的 cookie 以在值周围包含花括号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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