Want to see Parasoft in action? Sign up for our Monthly Demos! See Demos & Events >>
In a previous post, I offered some tips and tricks for testing Salesforce applications with Selenium. Salesforce provides a flexible development environment that allows developers to define their business logic and UI elements in an abstract way so that Salesforce can implement those elements on the page.
This flexibility comes at the expense of UI test automation because developers don’t have direct control over the final content in the browser. Salesforce enterprise apps are notoriously difficult to test with open source automation frameworks like Selenium.
To summarize the issues I discussed in my previous post, here are some of the reasons that testing Salesforce applications are difficult to automate with Selenium.
Element identifiers in a Salesforce app look very strange, for example, id=”940:1376;a”. Worse than that, the identifiers change randomly between page visits. This makes the identifiers useless for test automation.
Despite the name “Lightning,” Salesforce’s cloud-hosted enterprise apps can sometimes be quite slow. Test automation engineers are familiar with the challenges that come with applications that can be slow to respond. A test script will fail if it tries to perform the next step before the application is ready.
Another thorn in the side of UI test automation is that Salesforce remembers which Lightning UI components were last open and reinitializes the last known state upon login. This means that the initial page layout available to the test is subject to change depending on saved history.
The Salesforce Lightning UI has multiple updates every year. Each update may cause breaks for UI test automation. In such cases, AI-powered self-healing is needed to keep test automation working over such a frequent update schedule.
I offered tips and tricks to deal with these challenges. Although they’re helpful for getting Selenium to work with Salesforce applications, it’s still a lot of work. Luckily, there are tools to help.
Parasoft Selenic efficiently automates Selenium test creation and simplifies test maintenance. With Selenic, you can record interactions with Salesforce enterprise apps in your browser. Then easily create Selenium test classes that leverage all these same techniques.
Parasoft Selenic’s integrated Recorder provides an application selection so you can choose to gather Salesforce-specific attributes while recording UI actions. Selenic then incorporates those attributes when creating Selenium UI tests and uses AI technology to apply self-healing to tests that are broken due to changes in locators or wait conditions.
But wait. There’s more!
You can also leverage API testing and service virtualization to help make your Salesforce testing better, faster, and cheaper. Let’s look at how Parasoft can help you achieve all three.
The difficulty in using automation with Salesforce applications is likely to result in poor testing in general. Test coverage is probably low and increasing it requires significantly more work. To test these applications better, the test automation solution needs to make tests easier to create and maintain.
Selenic records the UI interactions during application execution and creates a reusable Selenium test as a result. Using a recording plugin for Chrome, Selenic intercepts all the UI interactions during application execution and identifies elements using the Selenium page object model, which improves the ability to uniquely identify locators despite the use of atypical identifiers in Salesforce applications.
The following illustrates the workflow of test creation with Selenic. Application interactions are recorded in the browser along with associated API calls (more on that later) and turned into Selenium Java projects in your IDE.
Tests are created quickly and easily from existing test scenarios and converted to Selenium tests in your IDE.
What happens when things change?
Selenium tests are somewhat fragile and quickly stop working after application changes are made. Selenic helps by providing self-healing for these broken tests.
Selenic continues to record interactions during subsequent test runs to detect changes since the previous test version and updates the tests based on detected differences such as failed locators and wait conditions.
Selenic also keeps track of performance metrics during recordings which can help benchmark and debug performance issues. The general workflow for Selenic self-healing is shown below.
Selenic’s AI heuristics diagnose test failures and automatically adjust missing elements to “heal” the tests. This works directly from the IDE as shown here and works just as well in a CI/CD pipeline. The recommendations made from the observed tests can be imported into the IDE and updated with a single click.
Automated generation combined with self-healing ensures that Selenium tests for Salesforce applications are less brittle and easier to maintain. This should help teams improve their automated testing significantly because they can reliably record entire test suites and reuse them without the traditional issues that plague Selenium testing. These tests are less likely to break due to changes in the UI and are easily maintained throughout the development life cycle.
Accelerating UI testing is very useful and the ROI on the investment in Selenium testing at UI level makes it worthwhile. Even with these improvements, testing at the UI is still a bottleneck and it’s more efficient to test business logic at the API level.
Fortunately, while recording UI test scenarios with Selenic, it’s also possible to record API interactions that are taking place using Parasoft SOAtest. These recordings, just like the UI interactions, are reused, parameterized, and modified to create API test scenarios.
SOAtest uses AI technology to analyze the complex data traffic patterns and locators and coalesce them into organized API tests. These API tests can then be applied to the application to test the same logic but without UI interaction. This greatly reduces the overhead of the tests and, with some tuning, the API tests can be pared down to the minimum interactions needed for testing a particular use case. The following shows the typical workflow for using SOAtest with Salesforce application API testing.
API level testing validates the business logic in the same manner as the original UI test case but with significantly lower execution times. Up to 97%. This means that test suites take much less time, and it also opens the possibility of expanding the testing to validate parts of the business logic being missed at the UI level.
SOAtest API tests are meant to be reused and parameterized as needed. New scenarios are created based on the original recordings with the addition of data sets created by the tester and auto-generated data as needed. A whole set of API tests are now possible from one simple recording by expanding the data sets for the tests.
By leveraging these flexible API tests, it’s possible to test more of the application since we have effectively removed the reliance on the UI for much of our testing. This independence means testing can scale quickly and much sooner in the development schedule.
Of course, API testing is great but there’s still the problem of the test execution environment. No enterprise system is without dependencies on external services and legacy systems. These are usually the bane of the testers since they either rule out production system testing altogether – requiring a reasonable facsimile in a lab – or make integration testing extremely risky. This is where service virtualization becomes essential to decouple the dependencies on these production systems.
Virtualized services provided by virtualization tools like Parasoft Virtualize are critical in decoupling applications under test from their complex production environments. Simulating dependencies means the application under test is decoupled from the production environment.
This provides complete control of data, on-demand deployment, and the ability to parallelize and speed up testing greatly, without the costs of pay-to-use APIs, a testing lab, or interfering with production systems.
Parasoft CTP’s environment manager makes it possible to map out the testing environment for the application under test and set up simulated services as needed. These services can provide realistic responses and support data models that mimic real-world services.
CTP provides a data model for the virtualized service and the ability to manage the data sets associated with the data model. The complexity of the virtualized service scales depending on the needs of the application being tested.
Service virtualization makes integration testing easier and cheaper. And also means testing sooner. You can shift API and integration testing much further to the left than ever before.
A key benefit of test automation is the ability to collect data and results during test execution. Parasoft DTP aggregates and analyzes data from the various testing practices used by the team to create a centralized view of quality. Further, it can correlate these test results back to your user stories in a requirements management tools such as Jira.
The ability to “connect the dots” between your use cases, test results, code coverage, and overall status is essential to making informed decisions. Team collaboration is improved because everyone sees the same source of truth on the status of the application and can act on the same information as needed.
Test automation of Salesforce applications can be troublesome. Using Selenium for UI testing is possible, but time-consuming to do without further tool assistance. Parasoft Selenic provides just the right assistance needed to make Selenium testing of Salesforce applications practical and to improve the outcomes of UI-based testing.
UI-based testing is important, but it’s an inefficient way to test all of an application’s business logic. API testing accelerates application testing while also improving the test coverage.
More tests are possible in a shorter time than UI testing. The impact of API testing is further improved with service virtualization, which decouples your Salesforce application from its complex and expensive production environment. The powerful combination of Parasoft SOAtest, Virtualize, and CTP means testing is more comprehensive and can be started earlier in the development cycle.
Finally, team collaboration improves with a centralized view of quality that comes from test automation at the various levels of the application. Parasoft DTP provides meaningful insights for sound decision-making and increases the ability of the organization to focus on innovation.
A Product Lead Engineer at Parasoft, Matt manages the development of new functionality for environment management, API testing, service virtualization, and test data modeling.