Beta Version: The API is under active development and may change without notice. Not recommended for production use until stable version is released.
Playwright Guide
Learn how to use OTPDock with Playwright to automate email verification flows in your end-to-end tests.
Installation
First, install the OTPDock client along with Playwright:
npm install -D @playwright/test @otpdock/client
Usage Example
Here's how to test a sign-up flow with email verification:
import { test, expect } from '@playwright/test';
import { OtpDockClient } from '@otpdock/client';
const client = new OtpDockClient('your_api_key_here'); // Get your API key from app.otpdock.com
test('sign-up with email verification', async ({ page }) => {
// Generate a temporary inbox
const inbox = await client.generateTemporaryInbox();
// Fill out the registration form
await page.goto('/sign-up');
await page.getByLabel(/Email/i).fill(inbox.email);
await page.getByLabel(/Password/i).fill('Test123!@#');
await page.getByRole('button', { name: /Create Account/i }).click();
// Wait for and retrieve the OTP code
const otp = await inbox.getOtp({ timeout: 20000 });
// Complete verification
await page.getByLabel(/Verification code/i).fill(otp);
await page.getByRole('button', { name: /Verify/i }).click();
});