0

I have a response body from one http request and I have to extract all the values and as input to another http request

<a class="action-link" 
 regionName="region name"
 jName="a country"
 alertID="179"
 onclick="showDetail(this)"> Snapshot- v4 (Active) 
</a>

i tried with regex like

  1. created a post processors -> regular expression extractors
  2. Apply to -> Main Sample Only
  3. Field to check -> Body
  4. Name of created variable -> regionNameVariable
  5. Regular Expression -> <a class="action-link" regionName=(.*?)

and passed the value as ${regionNameVariable} in the next request.

But It is not working. Can someone suggest the correct way of doing this.

F0cus
  • 585
  • 3
  • 18
  • 52

2 Answers2

0

Add multiple Regular expression extractor to extract each values

For example to extract the 3rd group in regex of Region Name(You can write better Regx if you have better idea)

enter image description here

Like Wise Add Regex for jName and alertID

  1. (jName)(=)\"(.+)\"
  2. (alertID)(=)\"(.+)\"

Then Pass on the Reference name as user variable in your next http request.as ${regionName} and so on.

If you want to do it in the same Regex post Processor. Please refer How to extract multiple values with a regular expression in Jmeter

Arjun Dev
  • 406
  • 5
  • 16
  • its not working Arjun. the request its passing like `regionName=%24%7BregionName%7D` – F0cus Jan 27 '20 at 06:33
  • Toggle Encode field in parameter where you are passing regionName. Disable and check or enable and check.In case... Some versions of Jmeter are buggy. Also Make sure that the content encoding in the http request sampler is utf-8. Just type utf-8 in the text field of content encoding. – Arjun Dev Jan 27 '20 at 08:46
0

Be aware that using regular expressions for parsing HTML is not a very good idea, consider using CSS Selector Extractor instead, the relevant configuration would be:

  • Name of created variable: regionNameVariable
  • CSS Selector Expression: a[class=action-link]
  • Attribute: regionName

Demo:

enter image description here

More information:

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