Example with Restmail.net

Restmail.net is probably the simplest toll to start with. It's free, it's requires no registration, it allows to create dynamically inboxes, it exposes a REST API to read received emails. However all the sent messages are public.

Let's take the previous test suite and modify it a bit. For Restmail.net we need user alias instead of email to check the inbox. So we can generate it like that.

As you see we also changed TEST_EMAIL template variable generation. Now it build based on earlier created TEST_USER_ALIAS one.

Next we find page.assignVarRemotely command and update the URL for of of Restmail.net:

http://restmail.net/mail/{{ TEST_USER_ALIAS }}

What we need now is a custom parser function in page.assignVarRemotely :

( json, payload ) => {
  const parseActivationLink = ( text ) => {
          const re = /(http\:[^\"]+4567\/con[^\"]+)/g,
                res = text.match( re );
          return res ? res[ 0 ].replace( "=\r\n", "" ) : null;
        sentAt =  payload.sentAt,
        unseen = json.find( msg => new Date( msg.receivedAt ) > new Date( sentAt ) );

  if ( !unseen ) {
    return null;

  return parseActivationLink( unseen.html );

The function has second parameter payload with sentAt property that contains sending event timestamp. Here we check if there are any messages received later then the application under test sent the activation email. If any found we parse it for the activation link.

Our page.assignVarRemotely command configuration shall look now like that:

Now we can save the changes and run the tests. On the generated screenshots we can see that a new account was created and activated.

Last updated