Videos
Check out our tutorial video series.
Automated Email Testing with WebDriver and MailSlurp: A simple way to test user sign-up and email confirmations using Selenium and Chrome.
This example demonstrates use of MailSlurp with NodeJS, Webdriver.io (WDIO), Selenium and Chrome to test user processes that depend on email. It tests user sign-up and email confirmation using the MailSlurp OAuth2 Playground as a dummy login application (shown below).
Each test run does the following:
MailSlurp is free for personal use so sign up to run the example yourself.
In order to test a websites login process you need to load the website into a browser and performs some actions against it. We will use WDIO for this example: a Javascript library that automates browsers.
To install create a file and paste the following:
Then run
Now add a file so we can configure WDIO to load the MailSlurp playground in the browser.
Create a test file called . Now let's configure MailSlurp:
Our first test should load the playground and assert the sign-up form is present.
If we run the test with we should see passing tests.
.
The first page to load is the login screen. As we want to sign-up let's click the link for that page in our test.
Now for the important part: creating a real email address on demand to sign-up a user with.
Notice how we created a new email address in each test run:
The inbox response object contains data like so:
The email address created is real and can receive emails sent from any application (including our login Playground).
Once the sign-up form has been submitted we can use MailSlurp to fetch the confirmation code and confirm the users account in the browser.
Notice the call to MailSlurp:
This call fetches the latest email in the given inbox or holds the connection open until the first email is received. This means the method will return the confirmation email sent by the Playground.
With our email address now confirmed lets log into the Playground and confirm we have access. A successful login should show a picture of a dog like so:
.
MailSlurp lets you send and receive emails from randomly assigned email addresses. It's great for testing authentication flows with Webdriver, Cypress, Jest and more. It's free for personal use so sign up today!
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.