I'll also be making some comparisons between Selenium and Endtest:
Selenium can only interact with HTML elements if they're in a browser.
This means that we'll have to open our email in a browser.
Luckily, anyone can use the Endtest Mailbox for free.
The way it works is similar to a disposable email service.
Simply send your email(s) to a email@example.com email address.
The username can be anything you choose.
For instance, you can choose something like firstname.lastname@example.org.
You can access the Inbox for that email address on that page.
Just add the email parameter in the URL, like this:
Please note that the emails will be deleted after 2 hours.
But for now, let's get back the Register page from Swit:
firstName = driver.find_element_by_id("firstName")
lastName = driver.find_element_by_id("lastName")
email = driver.find_element_by_id("id")
password = driver.find_element_by_id("password")
confirmPassword = driver.find_element_by_id("confirmPassword")
submitButton = driver.find_element_by_class_name("button--important")
And here is the result:
Now, if we want to check that email, we have to go to:
And we'll be able to open our email:
We just have to write that part with Selenium:
email = driver.find_element_by_class_name("email_item")
Since you're planning to run that test multiple times, you should generate a random email and store it in a variable and then append it to the Endtest Mailbox URL.
If you're looking for a better Selenium alternative, switch to Endtest.