Carol Castro
Carol Castro

Reputation: 25

Jmeter - Getting null value for variable on using regular expression extractor

On my Response data I have:

<td>
<input name="ids" type="checkbox" value="1080" class="select-checkbox"/>
</td>

And I have others lines

<td>
    <input name="ids" type="checkbox" value="1081" class="select-checkbox"/>
    </td>

<td>
    <input name="ids" type="checkbox" value="1082" class="select-checkbox"/>
    </td>

On my Regular Expression Extractor I have:

Reference Name: test
Regular Expression: input name="ids" type="checkbox" value="(.+?)" class="select-checkbox"
Template: $2$
Match No.: 0
Default Value:

But always the result is Null. Please, What I need to change?

Thanks

Upvotes: 1

Views: 1686

Answers (2)

Dmitri T
Dmitri T

Reputation: 168072

Don't use regular expressions to parse HTML, consider switching to CSS/JQuery extractor instead:

CSS_JQuery Extractor Demo JMeter

  • With Match No == 1 you will get test=1080
  • With Match No == 2 you will get test=1081
  • With Match No == 3 you will get test=1082
  • With Match No == -1 you will get:

    test_1=1080
    test_2=1081
    test_3=1082
    test_matchNr=3
    

If you are still looking for a Regular Expression Extractor solution - just use $1$ as a template, Match No follows the same rules as for the CSS/JQuery extractor, see JMeter - Regular Expressions guide for more details.

Upvotes: 0

Adnan
Adnan

Reputation: 2547

Change your regex configuration as follows:

Reference Name: test
Regular Expression: value="(.+?)"
Template: $1$
Match No.: 1
Default Value:

Output / Extracted data: 1080 (if Match no: 1)

Output / Extracted data: 1081 (if Match no: 2)

Output / Extracted data: 1082 (if Match no: 3)

Upvotes: 0

Related Questions