0

In JMeter, I have extracted multiple values in a page response to an arraylist using regex extractor (see extracted value below). I need to process the extracted values into an variable in the format (see required output below) and substitute in the following request. How can this be achieved?

Required Output: 44772164,44772175,44772176,44772177

Extracted Value

Match count: 4
Match[1][0]=propertyKey="44772164">
Match[1][1]=44772164
Match[2][0]=propertyKey="44772175">
Match[2][1]=44772175
Match[3][0]=propertyKey="44772176">
Match[3][1]=44772176
Match[4][0]=propertyKey="44772177">
halfer
  • 19,824
  • 17
  • 99
  • 186

1 Answers1

0
  1. It's not an "arraylist", however our understanding of what "arraylist" is might be different
  2. What you're showing doesn't look like JMeter Variables to me

If you used 'propertyKey' as the "Name of created variable" and your Regular Expression Extractor configuration look like:

enter image description here

You can generate your "Required Output" using a suitable JSR223 Test Element and the code like:

def requiredOutput = new StringBuilder()
1.upto(vars.get('propertyKey_matchNr') as int, {
    requiredOutput.append(vars.get('propertyKey_' + it))
    if (it  as int < vars.get('propertyKey_matchNr') as int) {
        requiredOutput.append(',')
    }
})

log.info('Required output: ' + requiredOutput as String)

Demo:

enter image description here Also be aware that using regular expressions for fetching data from HTML documents is not the best idea, you should rather use CSS Selector Extractor for HTML and XPath2 Extractor for XML.

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