5
votes

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.

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?

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

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"]

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]
1

1 Answers

6
votes

Try this one: //input[@type="hidden" and @name="token"]/@value

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