JMeter RE(Regular Expression) in WooCommerce is used to search and manipulate text, based on patterns. JMeter interprets forms of regular expressions or patterns being used throughout a JMeter test plan, by including the pattern-matching software.
For more details regarding Apache JMeter Regular Expression Extractor: Click Here
Steps to use the Regular Expression Extractor in Jmeter
1) Add a Regular Expression Extractor to a Sampler in your Test Plan.
right click on Sampler >> Add >> Post Processors >> Regular Expression Extractor
2) Set the name of the variable you want to store the extracted value in the “Name of created variable” field.
3) In Regular Expression, we can put the literals as per our need so that JMeter fetches the things. Literals must be in () brackets. The regular expression is used to capture dynamic values using (.+?).
For example, “We will add a product to the cart using SKU code” For that we will extract the product SKU, using the (.+?) regular expression.
Here,
dot(.) = Any character except line break
plus(+) = one or more times
question mark(?) = stop when first match succeeds
For more details regarding Regular Expressions: Check Blog
4) Now, we will add Group Number(Template), which are references or pointers to the groups.
It allows us to specify which group value to extract by specifying the group number as, ‘$1$’ will extract group 1, ‘$2$’ will extract group 2, and so on. $0$ will extract the entire expression.
5) Now, we will add Match No. we can define a number of strings from the complete body.
Let’s suppose in our body one string is present many times then tell JMeter to which string value is fetch by using Match Number. If we give 0 then it will automatically fetch any content.
6) Now we will add Default Value which is used in case the Regular expression does not match. This is an optional field. You may leave it blank.
7) Add View Results Tree listener for output.
right click on Thread Group >> Add >> Listener >> View result Tree.
Output
As a result, the product was successfully added to the cart.
For more details regarding JMeter Performance Testing, you can check the blog.
That’s all about JMeter RE in WooCommerce.
You can also check our complete WooCommerce plugin list.
For any further queries or suggestions add a ticket to our HelpDesk System.
Be the first to comment.