Tuesday, February 28, 2012
Regular expression Extractor - Testing ReCaptcha with JMeter
Most often these days every website that accepts payment want's to add additional security of having ReCaptcha inplace.
It is definitely a challenge to test reCaptcha without turning it off, but allowing to accept same password as against dynamically generated one.
So here's how i load tested reCaptcha using JMeter.
1.It is important that we know how to use the regular expression extractor,So that we retrive params from one request and pass them to another request.
2. Add a HTTP Sampler
3. We need to add Regular expression extractor which is required to retrive values from the response of the previous request. Therefore it would be a post processor.
3.a Right click on the HTTP Sampler > Add > Post Processors > Regular expression Extractor - see the screen shot
3.b Now the Regular Expression Extractor is added have a look at the screen shot,Let's have a closer look at it :
3.c Give appropriate name just like i have given ,It is however optional giving a name will help in debugging issues if it exists
3.d Apply to : leave this to default or choose as appropriate to your requirement
3.e Response Field to check : Leave this to default or choose as appropriate to your requirement
3.f Reference Name : Give a appropriate name here this act's as a variable that stores value retrieved from teh Regular expression
3.g Regular Expression : "params":"(.+?)nonce=(.+?)" Let's get to understanding this we are matching all that is after the params : and then matching the value for nonce
The special characters above are:
( and ) - these enclose the portion of the match string to be returned
. - match any character
+ - one or more times
? - don't be greedy, i.e. stop when first match succeeds
4. As i have previously mentioned it is good to add a DEBUG SAMPLER to understand whether right value is being fetched & for debugging purpose
5. Trick to validate your regular expression is :
5.a Add a View Results Tree
5.b Choose RegExp Tester to Validate if you have written the right expression
have a look at the screen shot