View on GitHub

examples

Email testing and SMS verification examples using MailSlurp and a wide range of frameworks.

SMS OTP testing with NUnit, C# and Playwright

This examples demonstrates how to use the MailSlurp C# library and phone numbers to test user sign-up and OTP SMS code verification.

It contains an NUnit Playwright test that loads a demo application and uses a MailSlurp phone number to sign up, receive an SMS verification code, extract the code, fill out the verification form, and complete user sign-up.

To get started see ./UnitTest1.cs

Key concepts

The important techniques in this test are:

The waitFor methods allow the test to wait until an expected SMS is received by your phone number. This means you don’t need retry methods or timeout waits.

Run

dotnet restore
dotnet tool install Microsoft.Playwright.CLI
dotnet playwright install

Test

Set API_KEY environment variable or override the test with your MailSlurp API key

Windows

$env:API_KEY="your-api-key"; dotnet test

Mac, Linux

API_KEY="your-api-key" dotnet test