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

查看:107
本文介绍了如何使用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天全站免登陆