WebdriverIO + plop.email

Add email verification to your WebdriverIO tests. Leverage WDIO's powerful async API and test runner capabilities.

WebdriverIO Documentation

Features

Built-in Test Runner

Integrated test runner with Mocha, Jasmine, or Cucumber support.

Multi-Browser Support

Test across Chrome, Firefox, Safari, and mobile browsers.

Service Integration

Easy integration with Sauce Labs, BrowserStack, and other services.

Page Object Pattern

Built-in support for maintainable test architecture.

Setup

# Install WebdriverIO
npm init wdio@latest ./

# Select your preferences in the wizard

# Add to wdio.conf.js
export const config = {
  // ... your config
  before: function () {
    global.PLOP_API_KEY = process.env.PLOP_API_KEY;
  },
};

WDIO Email Test

Test email flows with WebdriverIO.

WDIO Email Testtypescript
// test/specs/email.e2e.js
describe('Email verification', () => {
  it('should send welcome email after signup', async () => {
    const testEmail = `wdio+${Date.now()}@in.plop.email`;

    // Navigate and fill form
    await browser.url('/signup');
    await $('[name="email"]').setValue(testEmail);
    await $('[name="password"]').setValue('SecurePass123!');
    await $('button[type="submit"]').click();

    // Wait for success
    await expect($('.success-message')).toBeDisplayed();

    // Fetch email
    await browser.pause(2000);
    const response = await fetch(
      `https://api.plop.email/v1/messages/latest?to=${testEmail}`,
      { headers: { Authorization: `Bearer ${global.PLOP_API_KEY}` } }
    );
    const email = await response.json();

    // Assert
    expect(email.subject).toContain('Welcome');
    expect(email.htmlContent).toContain('Get Started');
  });
});

Custom Email Command

Add a reusable command for email fetching.

Custom Email Commandtypescript
// wdio.conf.js - Add custom command
export const config = {
  before: function () {
    browser.addCommand('getEmail', async function (toAddress) {
      const maxRetries = 5;
      const delay = 2000;

      for (let i = 0; i < maxRetries; i++) {
        const response = await fetch(
          `https://api.plop.email/v1/messages/latest?to=${toAddress}`,
          { headers: { Authorization: `Bearer ${process.env.PLOP_API_KEY}` } }
        );
        const data = await response.json();

        if (!data.error) return data;
        await browser.pause(delay);
      }
      throw new Error(`No email received for ${toAddress}`);
    });
  },
};

// Usage in test
describe('Password reset', () => {
  it('should receive reset email', async () => {
    const testEmail = `reset+${Date.now()}@in.plop.email`;

    await browser.url('/forgot-password');
    await $('[name="email"]').setValue(testEmail);
    await $('button').click();

    const email = await browser.getEmail(testEmail);
    expect(email.subject).toContain('Reset');
  });
});

Tips

  • Add custom commands for email operations to keep tests DRY
  • Use browser.pause() strategically for email delivery timing
  • Configure retries in wdio.conf.js for email-dependent tests
  • Use Allure reporter to capture email verification results

Related Integrations

Start testing with WebdriverIO

Add email verification to your WebdriverIO tests in minutes.