Automated Testing in Salesforce

Automated testing is a valuable approach for ensuring the quality and efficiency of Salesforce applications. However, there are certain pitfalls that testers may encounter when automating tests in the Salesforce environment. It's important to be aware of these pitfalls and implement strategies to overcome them. Let's explore some common pitfalls and discuss tips for creating a stable and effective test framework in Salesforce automation.

Testing strategy

For automated testing, the following strategy can be implemented for both no/low code and high coding tools.  The automation strategy is based on the DevOps principles.  

By creating user readable scenario’s, the test(results) can be reviewed by the key users or other stakeholders. By using the Gherkin language, the scenarios are also easily compared to user stories or requirements. After the planning phase, the coding phase starts, where the test automation engineer creates the tests. This can be done in a high coding manner or by recording or creating the steps in a no/low code application. In the deploy and monitor phase the test scripts run. Preferably in an automated pipeline. Then the results are monitored and analyzed, and the test engineers can act accordingly to the results. 

By implementing a strategy like this one, you can ensure a readable input and output, and a reusable test that gives fast feedback via automated runs, based on the DevOps principles.

Salesforce Test Automation Strategy

Testing via the GUI 

One common pitfall is the use of randomly generated ID attributes for locators. Salesforce generates dynamic IDs for web elements, making it challenging to reliably locate and interact with them during automation. Similarly, some elements may have insufficient or no attributes at all, making it difficult to build reliable locators. To overcome these challenges, it is advisable to use alternative approaches such as CSS selectors, XPath expressions, or other unique attributes that can reliably identify the desired elements.

Another potential challenge is presented by the complex tree structure of Salesforce, which can make it more challenging to navigate and interact with specific elements. Additionally, iframes may be present, further complicating the automation process. Testers need to devise strategies to handle these complexities, which may involve techniques such as switching frames or using specialized methods provided by automation frameworks to interact with iframes.

Salesforce applications often employ on-demand page loading strategies, where elements are loaded dynamically as the user interacts with the application. This can create difficulties in automation, as delays may occur when waiting for elements to appear or become interactable. Similarly, loading spinners may be present during data retrieval or processing. Testers need to implement appropriate wait mechanisms and synchronization techniques to handle these dynamic behaviors and ensure that tests proceed smoothly.

Testing via the API 

One effective way to avoid relying heavily on the GUI during automation is to leverage the Salesforce API capabilities. Salesforce provides robust API support, allowing testers to add or modify data, run SOQL queries directly on the platform, and perform various operations programmatically. By utilizing the APIs, testers can bypass GUI complexities and interact with Salesforce functionalities directly. 

Data driven testing or data validation in Salesforce can also be achieved via the Salesforce Data import/export functionality. Predefined data with for example test customer data or products can be uploaded in a few easy steps via tools like Salesforce Inpector or Mulesoft and via the setup. Data export can help with evidence logging or to create a snapshot of a default customer setup, so this can be used repeatably.

Developer Console  

Additionally, Salesforce offers its own Developer Console, built into the platform, which provides a powerful environment for writing code, executing commands, running APIs, and executing queries. Testers can leverage the Developer Console to perform complex automation tasks, interact with the platform programmatically, and streamline the testing process.

Salesforce and Automation, avoid the pitfalls

To delve deeper into Salesforce-specific automation pitfalls and strategies for overcoming them can be found in this wiki: Salesforce - Automation pitfalls



Building Blocks

Quality Engineering within Salesforce

Quality Assurance

Automated Testing

People involved



Related wiki's

   Look and feel 

    Automation pitfalls 

   Architecture and Releases  

   SuccessFactors explained