Puppetry
3.2.2
3.2.2
  • Welcome Puppetry
  • Getting Started
  • Project
  • Suite
  • Group
  • Target
    • Simple Target
    • iFrame Target
    • ShadowDOM Target
    • Chained Target
    • Shared Target
  • Test Case
  • Test Step / Action
    • Page Commands
    • Page Assertions
    • Target Commands
    • Target Assertions
  • Managing Records
  • Snippets
  • Running tests
    • Interactive Mode
    • Troubleshooting
  • Test Report
  • Export
    • Exporting as Jest Project (CI-friendly)
    • Exporting as Test Specification
  • Settings
  • Template Expressions
  • Testing Techniques
    • Testing Dynamic Content
    • Exhaustive Testing
    • Performance Testing
    • Visual Regression Testing
    • Testing Shadow DOM
    • Testing Google Analytics tracking code
    • Testing Chrome Extensions
    • Testing REST API
    • Mocking HTTP/S Requests
    • Testing Transactional Emails
      • Example with Restmail.net
      • Example with Mailinator
      • Example with IMAP bridge
      • Example with Google API
    • Testing Forms with Captcha
  • Version Control
  • Tips and Tricks
    • Embrace the Power of CSS
  • Command API
  • Test Application
Powered by GitBook
On this page
  • Testing Signup Flow
  • Template Variables
  • Test Targets
  • Test Case
  • Remote Service

Was this helpful?

  1. Testing Techniques

Testing Transactional Emails

PreviousMocking HTTP/S RequestsNextExample with Restmail.net

Last updated 5 years ago

Was this helpful?

Transactional email is a sort of email that require an action from the receiver side like in signup confirmation emails, password resets, purchase notifications and others. In order to automate testing of user flows involving transactional emails we need to be able to request the inbox contents from the testing tool. That can be achieved by using an email server with REST API or a specialized service such as , , , . These services are normally quite expensive, so alternatively we can develop a bridge one, which uses IMAP or, let’s say, Google API to access a public email server. Just to give it a try we can even go with Restmail.net, which is free and requires no registration or set up.

Puppetry provides page.assignVarRemotely command, which polls a given email server REST API until the desired email received (ot timeout). It retrieves the parsed the parsed value (e.g. activation link) and assigns it to a dynamic template variable accessible in all following test steps. The command can be configured to parse the received content.

Testing Signup Flow

To get a better grip on the idea we are going to create a simplified test project for built with . So the test scenario would be to type in required fields on the registration form, submit the form and use the link sent by email to activate the account.

Template Variables

Let's open Puppetry, create a new project and navigate to Settings. There we define our template variables:

Test Targets

Now we can define the test targets for the flow:

Test Case

First we need to ensure that we do no register an existing user. So we need to use a unique email address. That we achieve by dynamically assigning a template variable TEST_EMAIL that will accept during test run iterating values like test1@acme.com, test2@acme.com and so on.

Next we use page.goto to navigate to the signup page.

We type in email address generated in TEST_EMAIL.

We type in username, dynamically built with faker expression.

We type in password and password confirmation by using TEST_PASSWORD template variable, which we defined above.

Finally we click on Submit button.

That is supposed to bring us to the next page with the GDPR form.

So we wait until the page is ready

We make a screenshot.

We tick on the consent checkboxes.

We click on Register button.

We wait until the sent email arrives to the inbox and assign the parsed activation link to template variable ACTIVATION_LINK.

The we follow the link and make a new screenshot.

Remote Service

Now we can proceed with any of the following examples

What we need are BASE_URL ( NodeBB default one for development environment), which depends on testing environment and TEST_PASSWORD (fixture password used for registration) that once defined we can reuse across the project.

The registration form () has email, username, password, password confirmation inputs and submit button. We introduce these elements into Puppetry as REG_EMAIL_INPUT, REG_USERNAME_INPUT, REG_PASSWORD_INPUT, REG_CON_PASSWORD_INPUT, REG_SUBMIT_BTN. After submitting the form the application brings us to the GDPR form (), where we need to tick on consent checkboxes and click on Register button. Those elements we refer as REG_AGREE_EMAIL_CHECKBOX, REG_AGREE_DATA_CHECKBOX, REG_REGISTER_BTN.

http://localhost:4567/
see screenshot
see screenshot
Example with Restmail.net
Example with Mailinator
Example with IMAP bridge
Example with Google API
Sendgrid
Mailgun
Email Yak
Postmark
imaginary ACME forum
NodeBB
Signup flow variables
Signup flow targets
Signup test case, part 1
Signup test case, part 2