Salesforce Testing is a critical element of Salesforce administration and development. All Salesforce specialists need to apply testing methodologies to their areas of expertise. Whether you are an architect creating a complex integration, a marketer sending out a drip campaign, or an admin rolling out minor changes to a page layout, you must test your enhancement design in your environment against its original requirements.
This will identify potential errors, flaws, or areas for improvement. Just as you wouldn’t serve spaghetti without tasting it first, you should never release a Salesforce enhancement without testing it along the way. The Salesforce ecosystem is as customizable as it is complex. Ensuring enhancements and feature updates don’t crash or compromise other elements of your Salesforce environment will save you and your users substantial heartache.
Salesforce testing is the key to having smooth and efficient project deployment. This is especially true with automated functional testing where things, which you may not have considered during a build, pop up due to the amount of integrated and connected features within Salesforce.
Why Automate Salesforce Tests?
On a small scale, it’s possible to perform system checks manually. But, for large businesses, manual testing simply isn’t feasible. And without proper test coverage, risk is introduced.
Imagine, for example, a global enterprise that gets millions of visits on their customer-facing ecommerce site every day. If their system connections are down, even for a short amount of time, and they are not immediately notified, it can lead to a substantial loss of customers and profit. With the increased speed and accuracy of testing that test automation provides, this risk can be mitigated.
In addition to reducing risk, test automation can also help increase test coverage, speed up the overall software delivery release cycle, and enhance product quality, by ensuring efficient and accurate testing. To the business at large, this means reduced risk, reduced costs and competitive advantage.
Why Are Salesforce Tests Difficult to Automate?
Now that we’ve covered the benefits of test automation, let’s take a closer look at some of the things that make Salesforce automation difficult.
Although the Salesforce interface is designed in a way that offers numerous features and benefits to its users, the underlying software presents several challenges to those wishing to automate it.
Here are some of the reasons why Salesforce is difficult to automate from a technical perspective:
- Frequent system updates: Salesforce regularly update their platform to enhance user experiences or fix underlying issues. Unfortunately, these changes can impact user customizations and even standard uses of the platform. For QA teams, this means a lot of maintenance, and with a code-based automation platform, it means they must make changes to the code.
- Shadow DOMs: Salesforce uses Shadow DOMs to isolate components. This makes it difficult to identify elements in UI test automation.
- Element identifiers are hidden: Usually, a UI automation tool will need element details to identify visual elements in the application. Salesforce hides these for development purposes, making test automation difficult.
- Dynamic elements: UI elements that change with every test script run can be a real burden. Without an element locator strategy, maintenance of Salesforce tests will become a major time sink with every test run.
- Iframes: In Salesforce, a new tab is a new frame. These frames are difficult to identify because the UI automation tool needs to identify the elements under the frame. This can be difficult to automate with a script-based tool like Selenium and you’ll need to add that script logic in yourself, a task only for experienced Selenium testers.
- Heavy DOM structure: Salesforce’s DOM structure is heavy with a complex tree structure. This means that automation tools will need more time to access them.
You can see an example DOM structure below:
The next inevitable question is, of course, how best to overcome these automation challenges.
How Can You Automate Salesforce Testing?
There are two main paths you can choose between for Salesforce test automation: code-based frameworks or no-code automation tools. For this article, we will look at purely technical and high code (opposite of low-code) solutions. Some of the open source tools/frameworks, which you can use to automate Salesforce tests are:
- Selenium
- Robot
- WebdriverIO
- Cypress
- Playwright
- Codecept
- Karate
- Serenity
- Puppeteer
- UTAM
Most of these tools are Salesforce-agnostic so automation teams have to build frameworks on top of these from scratch.
TestZeus: Selenium Wrapper for Salesforce Test Automation
Given the nuances of Salesforce test automation, we came up with an innovative approach to test creation. This approach runs on the UI API and helps the automation team with the runtime creation of page objects. Also, as the locators are dynamically generated at runtime from the data provided by Salesforce, they are less prone to breakage and bring down the build time by at least 30%.
Working Mechanism
The core of the framework works on top of Salesforce’s UI API to achieve UI automation. Here is a resource on the API details.
TestZeus scrapes the sections, labels and data types from the UI API to create the stable locators and, based on the data types, contextually provides actions to interact with the UI.
Here is the flow of events in programmatic fashion:
- Hit the UI API via a connected app.
- Get the list of sections for the object.
- Recursively get the field types and labels for all the sections on the page.
- Create a data structure for the user interactions based on the test flow.
As the locators are created at run time based on the above data, users need not create page objects explicitly for the test case. These locators are passed onto standard Selenium based web driver to accurately perform the user interaction based on the test flow.
Ways to Use TestZeus
There are 2 easy ways of using TestZeus:
- Building on top of TestZeus: In case the automation team does not have an automation framework and they are building it from scratch, they can utilize the TestZeus framework as a boilerplate framework to kick start the automation efforts.
- Utilizing TestZeus in existing frameworks: As TestZeus is also available as a Maven package, it can be imported as a Maven dependency and the methods for interacting with UI can be utilized in existing frameworks.
Results
TestZeus brings value and results at three levels:
- Accelerates the test automation effort by removing the need for writing explicit locators.
- Adding stability via automatically waiting for the page to load.
- Reducing the maintenance effort for feature and platform level changes.
Summary
Test automation is key to the success of your Salesforce implementation. The tools and technologies need to be properly evaluated for the right kind of audience, tech stack, and org nuances. Generally, teams jump into a limited POC and repent later based on the initial choices.
Due diligence should therefore be done based on the business objectives of test automation and maturity of the team, its members, technology and processes.
Teams should invest early and properly in the test automation efforts to reap long term benefits, save on operating costs, and improve customer experiences.