Java 来自响应的 Jmeter 变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3652677/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 03:12:29  来源:igfitidea点击:

Jmeter variable from response

javajmeter

提问by breedish

Is it posible to bind to a variable value from response and then pass it as parameter to other http request?

是否可以从响应绑定到变量值,然后将其作为参数传递给其他 http 请求?

采纳答案by JoseK

The earlier answer to this is hopelessly outdated.

早先对此的回答已经无可救药地过时了。

Using the Post-Processor > Regular Expression Extractor, it is quite simple to extract any portion of the response.

使用后处理器 > 正则表达式提取器,提取响应的任何部分都非常简单。

The newer versions of JMeter also have Reg Exp tester options in the Listener > View Results in Tree, so you can perfect the regex till it does exactly what you want it to.

较新版本的 JMeter 在 Listener > View Results in Tree 中也有 Reg Exp 测试器选项,因此您可以完善正则表达式,直到它完全符合您的要求。

also see Passing variable from one http request to another in Jmeter

另请参阅在 Jmeter 中将变量从一个 http 请求传递到另一个



Earlier Answer:

之前的回答:

It should be possible to extract an element from the response using the Regular Expression Extractorand store it in a variable which can be referred from further requests.

应该可以使用正则表达式提取器从响应中提取元素并将其存储在一个变量中,该变量可以从进一步的请求中引用。

See Extract multiple stringson http://wiki.apache.org/jakarta-jmeter/RegularExpressionsand this example http://jmeter-tips.blogspot.com/2010/06/tip-12-how-to-add-http-request-sampler.html

请参阅http://wiki.apache.org/jakarta-jmeter/RegularExpressions上的提取多个字符串和此示例http://jmeter-tips.blogspot.com/2010/06/tip-12-how-to-add-http -request-sampler.html

The official docson this topic are this heading 19.5.1 __regexFunction

关于这个主题的官方文档是这个标题19.5.1 __regexFunction