Learn JMeter in 5 Hours

Start Learning
Slack

Run massively scalable performance tests on web, mobile, and APIs

How to Create a JMeter Script to Check Email During Registration AND Grab the Confirmation URL


Who said tricks are for kids?  Not us.  Especially when it comes to JMeter tricks and shortcuts.
 

Today, we'll review how to create a script sample which will allow you to check e-mail during the registration process and grab confirmation URL from the e-mail.  
 

Generally, registration is a core functionality that doesn't allow for bad performance, because we can get security holes, lost data and other “pleasant” things. That’s why registration should be tested in the first turn of the performance QA cycle. And e-mail verification is a standard part of this functionality. 
 
 
For my tests, I'll use Mantis BT, WAMP server and the Apache James mail-server. All this stuff, installed locally on my PC,  allows me to NOT trigger public e-mail services (e.g. Google, Yahoo, etc.), but rather, get  a pure isolated environment.

The Steps:
- Install WAMP server;
- Install and configure Mantis BT;
- Install Apache James mail server;
- Set up a user account at the mail server.
 
Once you complete the above steps, let's move onto the script.

Here is general screenshot of future script.

Future JMeter Script
 
First, I fill in the HTTP Request Defaults.

JMeter HTTP Request Defaults
 
Next element is User Defined Variables

JMeter scripting- user defined variables
 
And now – the Mail Reader Sampler

JMeter Mail Reader Sampler
 
With the help of this element you can login to mail server (Apache James, installed locally in our case), and read content of any folder.
 
What should we specify?
 
- mail protocol = pop3 (in our case);
- server host = localhost.localdomain;
- server port = 110;
- username = ${username}@localhost.localdomain, where ${username} will be taken from User Defined Variables;
- password = ${password}, where ${password} will be taken from User Defined Variables;
- folder = INBOX;
 
After we get a message/response from the server, we need to extract the confirmation  URL from it.

P.S. That’s why we added the Regular Expression Extractor as the child element for Get e-mail from James Server. 

Get email from Apache James Server
 
Note on the following two screenshots that the Regular Expression Extractor successfully grabbed the confirmation URL from the e-mail message.
 
JMeter Regex Extractor

Jmeter Regular Expressins Extractor
  
 
As you can see, this approach can be used during performance testing of local machines.
 
When testing from the cloud, like say The fabulous BlazeMeter load testing cloud...ahem, ahem...we only need make a slight change. Simply replace the e-mail server credentials from local to any public e-mail service (e.g. Google, Yahoo, etc.) where we have an account.
So, we don't need to change the structure of this script before uploading it to the cloud.
 
That's the magic behind the curtain.

 

You might also find these useful:

Interested in writing for our Blog?Send us a pitch!

Your email is required to complete the test. If you proceed, your test will be aborted.