gpt4 book ai didi

java - 如何将Jmeter Session本地存储放入Jmeter中

转载 作者:行者123 更新时间:2023-12-02 09:28:44 25 4
gpt4 key购买 nike

我需要将 Jmeter 内部的本地存储作为变量获取,以便我可以使用它进行进一步的身份验证。我添加了缓存管理器,但没有帮助。我做了一些研究,但没有帮助。

如有任何帮助,我们将不胜感激,谢谢。

最佳答案

根据 JMeter project main page:

JMeter is not a browser, it works at protocol level. As far as web-services and remote services are concerned, JMeter looks like a browser (or rather, multiple browsers); however JMeter does not perform all the actions supported by browsers. In particular, JMeter does not execute the Javascript found in HTML pages. Nor does it render the HTML pages as a browser does (it's possible to view the response as HTML etc., but the timings are not included in any samples, and only one sample in one thread is ever displayed at a time).

根据Window.localStorage描述:

The read-only localStorage property allows you to access a Storage object for the Document's origin

Document依次:

The Document interface represents any web page loaded in the browser and serves as an entry point into the web page's content, which is the DOM tree.

由于 JMeter 无法执行 JavaScript,您无权访问 Document 和 Window 对象,因此您无法从 localStorage 获取任何内容

使用 JavaScript 并从本地存储获取值的唯一方法是使用 WebDriver Sampler它提供了 JMeter 与 Selenium 的集成浏览器自动化框架,它又可以控制真实的浏览器和execute arbitrary JavaScript这样您就可以访问 localStorage 并从那里提取必要的值,这些值可以传递给 HTTP Request像平常一样的采样器JMeter Variables

关于java - 如何将Jmeter Session本地存储放入Jmeter中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58141536/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com