Automating verification of sent EMAIL/SMS messages



  • I have been doing some research about how to do verification automation on sent emails - but haven't really found anything that has worked thus far.

    Here is what I need to test:

    We have a customer portal where our customer service reps set a "Template" to be used for email and SMS communications. I am tasked with verifying that the email/SMS that is sent from us is received at our customers inbox with customer data and styling being the same.

    Our team has internal API's that I can use to execute the JSON requests to send the communications. Personally I have attempted to test this with Selenium by logging into a Gmail account and verifying the text that comes into the email, but it doesn't really check for the stylistic viewing of the email in the inbox. I haven't found any suitable SMS platform to see text messages. Any help on this issue would be appreciated.

    Update:

    Manual testing is not an option because we have 20 or so communication types and about 10 templates in each one. It takes a lot of time to test manually, so it really is a good candidate for automation with our small-er test team



  • Another similar service is mailosaur.

    Along with an API you can use to retrieve SMS (still beta as of September 2020) and emails, you can also use a number of packages/modules for a variety of testing frameworks.

    An example in TestCafe:

    import config from '../config';
    import { customAlphabet } from 'nanoid';
    import axios from 'axios';
    import Newsletter from '../Objects/newsletter';
    

    async function request (reqObject) {
    try {
    return await axios(reqObject);
    } catch (error) {
    console.error(error);
    }
    }

    function serverId () {
    return process.env.MAILOSAUR_SERVER_ID;
    }

    function mailosaurFullEmail (id) {
    return (id ? id : nanoid()) + '.' + serverId()
    + '@' + config.mailosaurDomain;
    }

    fixture Newsletter
    .page(baseUrl);

    test
    ('Sign Up For Newsletter', async t => {

        const id = (customAlphabet('1234567890', 10))();
    
        await t
            .typeText(Newsletter.newsEmailInput, mailosaurFullEmail(id))
            .click(Newsletter.consent)
            .click(Newsletter.sendButton);
    
        let res = await request({
            method: 'POST',
            url: config.mailosaurUrlEmail + serverId(),
            headers: {
                'Authorization': 'Basic ' 
                    + Buffer.from(process.env.MAILOSAUR_API_KEY)
                        .toString('base64'),
                'Content-Type': 'application/json'
            },
            data: {
                sentTo: mailosaurFullEmail(id)
            }
        });       
        
        await t
            .expect(res.status).eql(200);
    

    });

    
    <p>and the relevant config values:</p>
    <pre class="lang-json prettyprint-override"><code>{
        "mailosaurUrlEmail": "https://mailosaur.com/api/messages/await?server=",
        "mailosaurDomain": "mailosaur.io"
    }
    

    This endpoint will return 200 OK if the message was found and 204 if not.



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2