2
votes

I'm using JMeter 2.7 to load test a web application. I have a HTTP Request Sampler that returns a JSON document that has two values I want to extract from it. To do that, I have two RegEx PostProcessors assigned to the Sampler with the following configuration:

Regular Expression Extractor
Apply to: Main Sample Only
Response Field to Check: Body
Reference Name: val_1
Regular Expression: "val_1": "(\S+)"
Template: $1$
Match No.: 1

The configuration for the second is the same, just substituting val_2 for val_1. These seem like they should work.

Now, I also have a JSR223 PreProcessor script on a subsequent HTTP request that I want to use to transform the values I'm grabbing with the regex. However, the output of vars.get('val_1') and vars.get('val_2') are both null values. Tinkering with user-defined variables and "Apply to" settings haven't yielded any useful results.

Can anyone explain what I'm doing incorrectly? How can I use data retrieved through a RegEx extractor in my JSR223 script? Thanks in advance.

Edit - 9/26/2012
It was requested that I explain the structure a bit more, so here's an outline.

Thread Group
    Once Only Controller
        HTTP Sampler
            Regular Expression Extractor (for val_1)
            Regular Expression Extractor (for val_2)
    Some Additional Simple Controllers with HTTP Samplers Here
    Throughput Controller (80%)
        HTTP Sampler
            JSR223 PreProcessor (This is the PreProcessor in question)
            Regular Expression Extractor (to grab an unrelated value from the response)
    Some Additional Controllers with HTTP Samplers Here

Hopefully this is more helpful.

1
Can you give the structure of the test elements you describe here and how they are relateduser1565007
@PhilippeBossu - I updated my original post. Is this what you wanted?Todd

1 Answers

1
votes

Is your regexp "val_1": "(\S+)"?

can you add a debug sampler just after Http sampler to check that the 2 vars are defined. To do that add a tree result listener and see what debug sampler shows.