我如何使 cookies 值即 ai_user & JMeter 中的 ai_session 是动态的,因为它看起来不同 &每次用户点击主页请求时浏览器中的动态?

发布于 2025-01-11 00:21:33 字数 469 浏览 2 评论 0原文

每次我执行电子商务网站的主页时,一些 cookie 会出现在请求标头中,每次我们点击 主页请求 时,其中一些具有唯一的值,即 ai_user & ai_session。我想知道每次点击主页请求时如何在 JMeter 中获取这些唯一值。 我通过 blazemeter 记录了测试脚本,它自动将 HTTP CookieManager 中的所有 cookie 记录为用户定义的 cookie,但这些值是硬编码的,我希望它们在浏览器中工作时是动态的。 我已经更改了 jmeter 属性文件中的属性 CookieManager.save.cookies=true 。Jmeter.properties 文件位于 JMeter 的 bin 文件夹中,并在脚本中使用变量 ${COOKIE_ai_user}使用cookie值。 但问题是它的值是静态的我想让它动态,我该怎么做?

Each time I execute home page of ecommerce website, some cookies appear in request header some of them have unique values each time we hit Home request which is ai_user & ai_session. I want to know how do I get those unique values in JMeter for each time I hit home request.
I recorded test script by blaze meter and it automatically recorded all cookies in HTTP CookieManager as a user defined cookies but those values are hard coded I want them dynamic as it works in browser.
I already Change the property CookieManager.save.cookies=true in jmeter properties file.Jmeter.properties file is located in JMeter’s bin folder and use variable ${COOKIE_ai_user} in script to use cookie value.
But issue is its value is static I want to make it dynamic, how can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

罪#恶を代价 2025-01-18 00:21:33

每次我执行电子商务网站的主页时,请求标头中都会出现一些cookie

不,它不会那样工作。

  • 当您第一次打开页面时,浏览器会从Set-Cookie 标头
  • 当您下次打开页面时,浏览器将 Cookie 发送为 Cookie 标头

因此,当您在以下位置发送 cookie 时的情况第一个请求极不可能发生(除非您模拟返回用户)

添加 HTTP Cookie 管理器,它模拟浏览器的 cookie 存储并自动处理传入的 cookie。

Each time I execute home page of ecommerce website, some cookies appear in request header

No, it doesn't work that way.

  • When you open the page first time the browser gets cookies from Set-Cookie header
  • When you open the page next time the browser sends cookies as Cookie header

So the situation when you're sending cookies at the very first request is highly unlikely to happen (unless you're simulating a returning user)

It's sufficient to add HTTP Cookie Manager which simulates browser's cookie storage and automatically handles incoming cookies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文