如何使用 JMeter 从隐藏的输入字段中获取值 [英] How can I get the value from a hidden input field using JMeter

查看:18
本文介绍了如何使用 JMeter 从隐藏的输入字段中获取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从隐藏的输入字段中获取值.我研究并发现了许多站点(包括本站点上的实例)展示了很好的示例.当我尝试它们时,我无法使用我学到的方法从这个隐藏字段中检索值.我尝试了 xpath 提取器和正则表达式提取器,但都没有从隐藏字段中检索值.

I am trying to get the value from a hidden input field. I researched and found many sites ( including instances on this site ) showing great examples. When I try them, I am not able to retrieve the value from this hidden field using the methods I have learned. I have tried both an xpath extractor and a regular expression extractor, but neither one retrieves the value from the hidden field.

另外,我会注意到,在 JMeter 左侧的树中,我将提取器作为子项放入令牌首次出现的 HTTP 请求中.提取器应该是孩子还是应该与 HTTP 请求处于同一级别,但在测试流程中紧随其后?

Also, I will note that in the tree on the left side in JMeter, I put the extractors as a child to the HTTP Request where the token first appears. Are the extractors supposed to be children or are they supposed to be at the same level as the HTTP Request, but just after it in the flow of the test?

================================

==============================

在这里,我将解释我的设置.有来自表单的 HTTP 请求.表格上有一个标记.我需要获取此令牌的值.这是出现令牌的页面的 html:

Here, I will explain my set up. There is an HTTP request from a form. There is a token on the form. I need to get the value for this token. Here is the html for the page where the token appears:

<form action="/folder1/part1/save/12345-1234-1234-1234-123456789012" method="post" name="mgr" id="mgr" >
<input type="hidden" name="token" value="1234-12-12-12-1234" id="token" />

================================

==============================

对于正则表达式提取器,我已经尝试了所有这些,每次测试运行一次:

For the Regular Expression Extractor, I have tried all of these, one at a time for each test run:

//input[@type="hidden" and name="token"]/@value
//input[@type="hidden"][@name="token"]/@value
//input[@type="hidden"]/[@name="token"]/@value
//input[@type="hidden"][@name="token"]/@value/[@id="token"]
//input[@type="hidden"]/[@name="token"]/@value/[@id="token"]

对于 XPath 提取器,我已经尝试了所有这些,每次测试运行一次:

For the XPath Extractor, I have tried all of these, one at a time for each test run:

//[@id="token"]
/html/body/div/div[2]/div/form/input[1]
//html/body/div/div[2]/div/form/input[1]

推荐答案

试试这个://input[@type="hidden" and @name="token"]/@value

此外,您可以完全在 JMeter 中测试您的表达式.例如,您可以在查看结果中的 XPath Tester 元素中检查此 xpath 提取树侦听器.在那里你也可以找到 Regexp Tester

Also, you could test your expressions exactly in JMeter. For example, this xpath extraction you could check in XPath Tester element in View Result Tree Listener. There you could find Regexp Tester too

这篇关于如何使用 JMeter 从隐藏的输入字段中获取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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