How can I get a value from a hidden input field using JMeter

I am trying to get a value from a hidden input field. I researched and found many sites (including instances on this site), showing excellent examples. When I try them, I cannot extract the value from this hidden field using the methods I learned. I tried both the xpath extractor and the regex extraction tool, but none of them extract a value from a hidden field.

In addition, I want to note that in the tree on the left in JMeter, I put extractors as a child in the HTTP request, where the token first appears. Are the extractors supposed children or should they be at the same level as the HTTP request, but immediately after it in the test flow?

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

Here I will explain my setup. There is an HTTP request from the 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 regex extent, I tried all of this, one 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"]

For XPath Extractor, I tried all of this, one for each test run:

//[@id="token"]
/html/body/div/div[2]/div/form/input[1]
//html/body/div/div[2]/div/form/input[1]
+4
source share
1 answer

Try the following: //input[@type="hidden" and @name="token"]/@value

Alternatively, you can test your expressions exactly in JMeter. For example, this is xpath extraction, which you can check in XPath Tester in the View Viewer Tree Listener. There you can also find the Regexp tester.

+5
source

Source: https://habr.com/ru/post/1524313/


All Articles