Videos
Check out our tutorial video series.
How to receive email and open firebase verification links in Appium tests.
Appium is crucial tool in mobile QA and integration testing and many teams use Appium with Selenium to test Android applications end-to-end. Most applications have a sign-up process and testing this with real email accounts is essential for reliable app deployments. In this tutorial we'll show you how to create disposable email accounts, connect them to your Appium tests and then receive verification codes to confirm an account.
Full code for this tutorial can be found on GitHub
Authentication providers like Firebase commonly use email based account verification or MFA. This typically involves sending a new user a unique link that must be opened in order to validate an account sign-up. Testing this process is the best way to ensure critical aspects of an app are functioning correctly. We can do this with temporary mailboxes with the free service MailSlurp.
Let's write a test for an example application. Our test app uses Firebase Auth UI to allow user sign-up using email and password. After signing up the user is presented with a confirmation screen and must open their email and click a link to complete the sign-up. The app looks like this:
In order to test this we will use Appium, Selenium, and MailSlurp to integrate disposable mailboxes that expire after each run and provide a unique user for every test.
Okay, let's get started. First, we will assume you have Android studio setup with Appium installed (if not see the github repository). Next add the package from Maven central to your build.gradle.kts.
Add the MailSlurp client to your dependencies file so we can control emails.
Then in tests import the client like so:
Now inside a typical Appium test we might have a setup like this:
This will open the test application using the Appium selenium hub. We must enable that hub before each test run in another terminal. We use a Makefile like so:
Next we can test our application sign up. Let's go!
First we will load the activity:
We should see a sign-up form waiting for an email and password.
Next we create a new email account by using the MailSlurp inbox controller:
This is a real email account that can receive emails like those 2FA links sent by Firebase Auth. Next we can open that email and extract out the link.
MailSlurp is free you just need a valid API KEY
Now we submit the email account and dummy password to simulate user sign-up. Here we fill the form inputs with the recently created email address and a random password then click "create account".
This is what a filled form looks like. You can see a randomized email account in the user field.
After submitting we can expect an email to be sent to the inbox. Let's read it.
In the next step we use MailSlurp wait for methods to hold the test open until the email is received by MailSlurp in the background.
After clicking the verify button an email is sent and we use the Wait controller to wait for a matching email in the test inbox:
You can see at the end we verify the email arrived and has expected subject.
Now we can extract the link from the email body using the MailSlurp email controller. After fetching the link we can open it in a chrome browser using the using the deep link method:
It's a little unusual but it works! The link url loads in a browser and tells us the user is now verified.
Wonderful! Lastly, we can navigate back to our test application and see that the user account is now showing confirmed.
Wow! We just tested email verification in appium. We used MailSlurp's free email accounts to receive the confirmation and opened the email link using the selenium driver.
You can add temp email accounts and open real email during your Appium QA tests to ensure your apps key processes are functional. That means user sign-up, password reset, and real notifications. If you use Firebase auth or any other MFA auth provider check out MailSlurp today.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.