As the holiday season approaches, businesses ramp up their marketing efforts to attract customers with enticing Black Friday deals. But with the excitement of discounts comes the necessity of ensuring that every aspect of the user experience is flawless—especially the communication that leads to conversions. From promotional emails to SMS alerts containing codes and links, testing these messages is essential for a successful Black Friday campaign.
Why you need to test any links and promo codes for Black Friday?
Black Friday is a peak shopping event, and customers expect instant gratification. They want to receive deals quickly and easily, whether via email or SMS. Testing links and codes with Selenium ensures:
- Functional Links: All promotional links direct customers to the correct product pages or special offers.
- Accurate Codes: Discount codes provided in emails or SMS work as intended, providing the expected savings.
- Smooth User Journey: Every interaction, from receiving a promotional message to successfully completing a purchase, works without a hitch.
Start testing links and promo codes
In this article we'll give you a quick idea of how Mailosaur can be used to set this kind of scenario. It's essential to verify that all promotional links and codes are functioning correctly. By testing with Selenium, you can automate this process and quickly identify any issues before they impact your sales. Here's how to test your links and promo codes effectively:
Set up a simple Selenium project
You can quickly generate a basic starter project, including Mailosaur integration, which will install and set up Mailosaur in a sample project:
npm create mailosaur@latest
For more detailed instructions, or to manually integrate Mailosaur with an existing project, check out the full guide in our documentation.
Testing promotional email links with Selenium
During Black Friday, businesses often send promotional emails featuring limited-time deals. Testing these emails for correct link functionality is crucial to drive sales.
Send a Promotional Email: Use Selenium to trigger the sending of a promotional email by simulating an action (like a new product launch).
Capture the Email: With Mailosaur, retrieve the email sent to the designated testing inbox. Access the message content to ensure it contains the expected promotional details.
String apiKey = "API_KEY";
String serverId = "SERVER_ID"; // The unique ID of the inbox (server) that you are using
// Create a MailosaurClient instance, using your API key
MailosaurClient m = new MailosaurClient(apiKey);
// Using the serverId you can create an email address for this test case
String testEmail = m.servers().generateEmailAddress(serverId);
// NOTE You don't need to create email addresses, you could just make one up
// String testEmail = String.format("my-test@%s.mailosaur.net", serverId);
// ----------------------------------------------------------------------------------
// TODO Do something here that triggers a promotional email to be sent to `testEmail`
// ----------------------------------------------------------------------------------
// Provide the ID of the inbox (server) that you're using
MessageSearchParams params = new MessageSearchParams();
params.withServer(serverId);
// Provide the search criteria (this searches for any message sent to this address)
SearchCriteria criteria = new SearchCriteria();
criteria.withSentTo(testEmail);
// Get the latest message that matches your criteria
Message msg = m.messages().get(params, criteria);
// Now you can perform test assertions
assertEquals("Black Friday deals!", msg.subject());
// Check for content within an email
assertTrue(msg.html().body().contains("Shop with us this Black Friday"));
// Extract the link from the email
Link link = msg.html().links().get(0);
assertEquals("Shop now", link.text());
// Navigate to the link to verify it is correct
browser.get(link.href());
assertEquals("Black Friday deals", browser.getTitle());
browser.quit();
Extract and Validate Links with Selenium
Use Selenium to parse the email and extract any links. Verify that these links lead to the correct landing pages or product pages.
Link link = msg.html().links().get(0);
assertEquals("Shop now", link.text());
browser.get(link.href());
assertEquals("Black Friday deals", browser.getTitle());
Testing discount codes in emails with Selenium
Emails sent during Black Friday often include discount codes to entice customers. Ensuring these codes work correctly during checkout is vital for customer satisfaction.
Send a discount code email: Simulate an action that triggers the sending of an email with a discount code, such as a newsletter signup.
Retrieve and parse the Email: Use Mailosaur to capture the email, then extract the discount code from the email body.
Apply the discount code: With Selenium, navigate to the checkout page, enter the extracted discount code, and verify that the discount is applied correctly.
// Extract the discount code from the email
Code discountCode = msg.html().codes().get(0);
// Navigate to your checkout to confirm the code works
browser.get("www.yourshop.com/checkout");
assertEquals("Checkout", browser.getTitle());
browser.findElement(By.cssSelector("input#discountCode")).sendKeys(discountCode.value());
browser.findElement(By.cssSelector("button[type='submit']")).click();
browser.findElement(By.id("discountApplied")).isDisplayed();
browser.quit();
Testing SMS alerts for flash sales with Selenium
During Black Friday, SMS alerts are often sent out to notify customers of flash sales. Testing these alerts ensures that customers receive the correct codes and links in real-time.
Trigger an SMS alert: Simulate the action that sends an SMS alert about a flash sale (e.g., a customer subscribing to updates).
Capture the SMS with Mailosaur: Use Mailosaur to receive the SMS, ensuring you capture the correct message format.
String apiKey = "API_KEY";
String serverId = "SERVER_ID"; // The unique ID of the inbox (server) that you are using
// Add Mailosaur testing phone number to this variable
String phoneNumber = "PHONE_NUMBER";
// Create a MailosaurClient instance, using your API key
MailosaurClient mailosaur = new MailosaurClient(apiKey);
// ----------------------------------------------------------------------------------
// TODO Do something here that triggers a promotional sms to be sent to `phoneNumber`
// ----------------------------------------------------------------------------------
// Provide the ID of the inbox (server) that you're using
MessageSearchParams params = new MessageSearchParams();
params.withServer(serverId);
// Provide the search criteria (this searches for any sms sent to this phone number)
SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.withSentTo(phoneNumber);
// Get the latest sms that matches your criteria
Message sms = mailosaur.messages().get(params, searchCriteria);
// Extract the link from the sms
Link link = sms.html().links().get(0);
// Extract the discount code from the sms
Code discountCode = sms.text().codes().get(0);
// Navigate to the link to verify it is correct
browser.get(link.href());
assertEquals("Black Friday deals", browser.getTitle());
// Navigate to your checkout to confirm the code works
browser.get("www.yourshop.com/checkout");
assertEquals("Checkout", browser.getTitle());
browser.findElement(By.cssSelector("input#discountCode")).sendKeys(discountCode.value());
browser.findElement(By.cssSelector("button[type='submit']")).click();
browser.findElement(By.id("discountApplied")).isDisplayed();
browser.quit();
Extract the code and link with Selenium
Parse the SMS to extract the discount code and any relevant links.
Link link = sms.html().links().get(0);
Code discountCode = sms.text().codes().get(0);
Submit the Code
With Selenium, enter the discount code into the checkout page and navigate to any associated links to ensure they work properly.
browser.get(link.href());
assertEquals("Black Friday deals", browser.getTitle());
browser.get("www.yourshop.com/checkout");
assertEquals("Checkout", browser.getTitle());
browser.findElement(By.cssSelector("input#discountCode")).sendKeys(discountCode.value());
browser.findElement(By.cssSelector("button[type='submit']")).click();
browser.findElement(By.id("discountApplied")).isDisplayed();
As Black Friday approaches, ensuring that your email and SMS communications function correctly is more important than ever. Automating the testing of links and codes with Selenium and Mailosaur can help you provide a seamless shopping experience for your customers, boosting satisfaction and conversion rates.
Try it for yourself
By thoroughly testing every message, link, and code, you can confidently roll out your Black Friday campaigns, knowing that your customers will have a smooth journey from email or SMS, notification to purchase. You can try Mailosaur for free for 14 days.
And naturally, if you’d like to learn more about what Mailosaur can do in Selenium, you can speak to our sales team, or read our documents for Selenium.