Skip to main content

Receive Email

def receive_email(driver: TestUIDriver, address: str) -> []

This custom command will return an array of email messages that were sent to the specified email address during test execution. To generate the email address, you should use the gen_email function.

The command itself will not wait for any messages to arrive, so it's recommended to use it within a loop that will wait for the email to be visible within the the array.

The email message object will have the following properties:

  • from - The email address of the sender.
  • subject - The subject of the email.
  • headers - The headers of the email.
  • text/plain - The plain text content of the email.
  • text/html - The HTML content of the email.
def test(driver: TestUIDriver):
emails = receive_email(driver, gen_email("test"))

print("Amount of received emails:", len(emails))

for email in emails:
print("From:", email["from"])
print("Subject:", email["subject"])
print("Plain text content:", email["text/plain"])