This project demonstrates OTP email verification testing using Selenium WebDriver and MailSlurp API within a MuleSoft Anypoint project structure.
The test performs a complete email verification flow on the MailSlurp playground site:
- Create Inbox - Creates a real email inbox via MailSlurp API
- Sign Up - Fills in the signup form with the generated email address
- Receive Email - Waits for the verification email using
waitForLatestEmail - Extract OTP - Extracts the 6-digit verification code using regex
([0-9]{6})$ - Verify Account - Submits the OTP code to confirm the account
- Login - Logs in with the confirmed credentials
- Assert Welcome - Verifies the "Welcome" text appears after login
- Java 8 or higher
- Maven 3.6+
- Google Chrome browser installed
- A MailSlurp API key (get one free at https://app.mailslurp.com)
The test uses the MAILSLURP_API_KEY environment variable for authentication with the MailSlurp API.
Set your MailSlurp API key and run:
# Using the API_KEY or MAILSLURP_API_KEY environment variable
MAILSLURP_API_KEY=your_api_key_here mvn test
# Or export it first
export MAILSLURP_API_KEY=your_api_key_here
mvn testmulesoft-project/
├── pom.xml # Maven configuration with dependencies
├── README.md # This file
└── src/
├── main/
│ └── java/
│ └── com/smoketest/selenium/
└── test/
└── java/
└── com/smoketest/selenium/
└── OtpEmailVerificationTest.java # Full OTP email test
- Selenium WebDriver (4.18.1) - Browser automation
- MailSlurp Java Client (17.0.0) - Email inbox creation and retrieval
- JUnit 4 (4.13.2) - Test framework
- SLF4J (2.0.5) - Logging
| Setting | Value |
|---|---|
| Browser | Chrome |
| Timeout | 60 seconds |
| Target URL | https://playground.mailslurp.com |
| Test Password | test-password |
To run in headless mode (no visible browser window), uncomment this line in OtpEmailVerificationTest.java:
options.addArguments("--headless");- ChromeDriver not found: Selenium 4.6+ includes automatic driver management. Ensure Chrome is installed.
- API key invalid: Verify your MAILSLURP_API_KEY environment variable is set correctly.
- Timeout errors: Increase
TIMEOUT_MILLISif on a slow network connection.
This project is for demonstration purposes as part of MuleSoft Anypoint testing examples.