how to extract input type = hidden in jmeter using regularexpression extractor or cssextractor or xpath extractor

I want to get the value of input type = "hidden" name = "CRAFT_CSRF_TOKEN" value="dfsdgdg"

below is the response that I am getting for my first request. I want to read the value from the first request and use it in my subsequent request. I tried using a regular expression extractor, CSS selector extractor and XPath extractor none of them workedenter image description hereenter image description here input type="hidden" name="CRAFT_CSRF_TOKEN" value="4edwUQQn9gYbf5zYjz4fuRIfyu3lzoXi3_27IU7Jj54RLskSWvVvnKadSTdGYpVofQmqn79hT9dHLYeBsZf0h6-M9HErsMb6eXiHWTXHXt4="

Upvotes: 1

Views: 1252

Answers (2)

Janesh Kodikara
Janesh Kodikara

Reputation: 1821

You can use the XPath Extractor, XPath2 Extractor and CSS Extractor as in the other answer. They all work well if your response is a valid HTML.

Here is another option with a Regular Expression Extractor.

enter image description here

Regular expression

name="CRAFT_CSRF_TOKEN" value="(.*?)"

Note: You can validate the syntax of regular expressions, CSS, XPath, etc in the View Result Tree.

Upvotes: 1

Dmitri T
Dmitri T

Reputation: 168002

  1. XPath: //input[@type='hidden' and @name='CRAFT_CSRF_TOKEN']/@value

    enter image description here

    However it's better to go for XPath2 (the same syntax can be used)

    enter image description here

  2. CSS: input[type=hidden][name=CRAFT_CSRF_TOKEN]

    enter image description here

Upvotes: 1

Related Questions