0

I have some head information from which I would like to extract the "RequestVerificationToken" value associated with the id ="LoginToken".

So in sample below I am after the value starting with "kL5Ukn...".

<span id="loginToken"><input name="__RequestVerificationToken" type="hidden" value="kL5UknRMXsBy5QUMtDFPuBwESd89jK5l1VyF7SliGL8g0NCE-pnbowPMPtEMpi2Nmm9F_626FN-cQ6-miwS-CXXkQUM1" /></span>

<span id="registerToken"><input name="__RequestVerificationToken" type="hidden" value="JDJD9khCZNjXeFGLMcBbqDqNmgR19Z-wy4FueH1CkWCdQQry_cgnKHLuj7uyrquk_gzDotKxN1ZQO8rPEc3fsH21uXc1" /></span>

Thanks

ratsstack
  • 1,012
  • 4
  • 13
  • 32

2 Answers2

1

Try Regex: id="loginToken".*?value="(.*?)"

and retrieve Group 1.

Demo

Matt.G
  • 3,586
  • 2
  • 10
  • 23
1

Using regular expressions to parse HTML is not the best idea as regular expressions are:

  • hard to develop and maintain
  • hard to read
  • fragile and sensitive to markup changes as attributes position change or a new line will ruin your script while the response will still be a valid HTML

So I would recommend going for CSS/JQuery Extractor instead, the relevant configuration would be:

  • Reference name: anything meaningful, i.e. token
  • CSS/JQuery expression: span[id=loginToken] > input[name=__RequestVerificationToken]
  • Attribute: value

Other settings may be left intact.

Demo:

JMeter CSS/JQuery Extractor Demo

Dmitri T
  • 159,985
  • 5
  • 83
  • 133