0
votes

I am new to JMeter and learning, practicing using the Regular expression extractor.

I have created a test plan using the recorder. I have added a regular expression extractor as i want to get the text "Your Account" from my webpage into a variable.

I use the debug sampler to check if my variable has got the value "Your Account" in there. I am seeing the default value "your_account_NONE" in the variable when i run the test.

I think my regular expression is wrong. Please advise, help. Thanks.

I know I am on the correct page when the test runs because i have inserted a Response Assertion, pattern to test is set to "Your Account" The assertion passes. If i change to pattern to "Your Accounttttttttttt" The assertion fails. So I am on the correct page. I would like to get the value "Your Account" into a variable.

My regular expression has the following config:

Reference Name: YourAccount
Regular Expression: <h1>"Your "   <span>Account</span> </h1>
Template: $1$
Match: 1
Default Value: your_account_NONE

My test plan is as follows:

Test Plan
   Thread Group
   Http Request defaults (Server Name: a URL to go to homepage)
   Recording Controller
      Http Cache Manager
      Http Cookie Manager
      Http request (sign in)
      http request (Homepage)
         Regular Expression Extractor
         Response Assertion
1

1 Answers

1
votes

The solution to this issue is to use Regular Expression Character Groupings. These are then referenced in the "Template" portion of the regular expression extractor.

Simply encase the part of the match you want in ().

For example:

 Regular Expression: <h1>"(Your )"   <span>(Account)</span> </h1>

The line above places a character grouping around "Your " and "Account". Then, to build that into one reference variable you want your "Template" to be this:

$1$$2$

That will concatenate the two character groupings into the variable "YourAccount".