Gayathri Alen
Gayathri Alen

Reputation: 11

how can i extract a hidden value passed through an http request in jmeter and post it in next sampler

I see the otp passed like this. I need to extract the OTP and post it in the OTP field request <input type="hidden" name="CCus" value="TesSS4550379362465"> <input type="hidden" name="OTPHidden" value="Z5oJYn">

Upvotes: 1

Views: 1752

Answers (1)

Dmitri T
Dmitri T

Reputation: 168092

There are several options:

  1. Using Regular Expression Extractor like:

    • Reference Name: any variable name, i.e. OTP
    • Regular Expression: <input type="hidden" name="OTPHidden" value="(.+?)">
    • Template: $1$
  2. Using XPath Extractor like:

    • Use Tidy - check. It might not be required if your response is XML/XHTML-compliant
    • Reference Name: OTP
    • XPath query: //input[@name='OTPHidden']/@value
  3. Using CSS/JQuery Extractor like:

    • Reference Name: OTP
    • CSS/JQuery Expression: input[name=OTPHidden]
    • Attribute: value

In all cases refer the extracted value as ${OTP} in the next request.


In regards to which option to choose:

  • If your markup doesn't change frequently and the input always comes in one line - go for Regular Expressions
  • If your page has complex DOM and not very complex styles - go for CSS/JQuery
  • If there are many styles but DOM is relatively simple - use XPath

Upvotes: 4

Related Questions