In a previous article, I provided some tips and tricks for testing Salesforce applications using 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 them on the page.
This flexibility comes at the expense of UI test automation. Because the developer has no direct control over what ends up in the browser. Salesforce enterprise applications are notoriously difficult to test using open source automation frameworks such as Selenium.
Why is It difficult to test Salesforce with Selenium?
To summarize the issues I discussed in my last article, here are some of the reasons why testing Salesforce applications using Selenium is difficult to automate.
Dynamic element identifiers
Element identifiers in Salesforce applications look very strange, for example, id=”940:1376; A “. Worse than that, identifiers change randomly between page visits. This makes identifiers useless for test automation.
Cloud hosted enterprise applications are slow
Despite its name, Salesforce’s cloud-hosted enterprise apps can sometimes be pretty slow. Test automation engineers are familiar with the challenges of slow-responding applications. If the test script tries to execute the next step before the application is ready, it will fail.
Remember and re-initialize the Lightning UI component
Another thorny issue with UI test automation is that Salesforce remembers which Lightning UI components were opened last and reinitializes the last known state at login. This means that the initial page layout available for testing changes based on the saved history.
Frequent Salesforce software updates
The Salesforce Lightning UI is updated multiple times each year. Each update may result in an interruption of UI test automation. In this case, ai-driven self-healing is required in order for test automation to work with such a frequent update schedule.
In that article (20.10.1), I provided tips and methods for addressing these challenges. To meet these challenges. While they are helpful for getting Selenium to work with Salesforce applications, it is still a big effort. Fortunately, there are tools available to help.
Use AI technology to enhance Selenium automated UI testing capabilities
Parasoft Selenic effectively automates Selenium test creation and simplifies test maintenance. Using Selenic, you can record your interactions with Salesforce Enterprise applications in your browser. Then you can easily create Selenium test classes that leverage all of these same techniques.
Parasoft Selenic’s integrated Recorder provides an application selection, so you can choose to collect Salesforces-specific properties while logging UI actions. Selenic then incorporates these attributes when creating Selenium UI tests and uses AI techniques to self-repair the tests. Broken by a locator change or by waiting conditions.
But wait. There’s more!
You can also leverage API testing and service virtualization to help make your Salesforce tests better, faster, and cheaper. Let’s take a look at how Parasoft can help you achieve all three.
Test your Salesforce application better
The difficulty of using automation in Salesforce applications is likely to result in poor testing in general. Test coverage can be low, and increasing coverage requires a significant increase in effort. To better test these applications, test automation solutions need to make tests easier to create and maintain.
Selenic records UI interactions during application execution and creates a reusable Selenium test. Using the Logging plug-in for the Chrome browser, Selenic intercepts all UI interactions during application execution and identifies elements using the Selenium page object model, which increases the ability to uniquely identify locators despite the use of atypical identifiers in Salesforce applications.
The following describes the workflow for creating tests using Selenic. Application interactions are documented in the browser (more on that later) along with associated API calls, and become Selenium Java projects in the IDE.
Tests can be quickly and easily created from existing test scenarios and converted to Selenium tests in the IDE.
What happens when things change?
Selenium testing is somewhat fragile and stops working very quickly when the application changes. Selenic helps you by providing self-healing for these damage tests.
Selenic continues to record interactions in subsequent test runs to detect changes since the last test version, and updates tests based on detected differences, such as failed locators and wait conditions.
Selenic also tracks performance metrics during recording, which can help benchmark and debug performance issues. The general workflow of Selenic self-healing is described below.
Selenic’s AI heuristic diagnostic test fails and automatically adjusts the missing element to “cure” the test. This works directly from the IDE, as shown here, and works equally well in the CI/CD pipeline. Recommendations from observed tests can be imported into the IDE and updated with one click.
The combination of automatic generation and self-healing ensures that Selenium tests are less brittle and easier to maintain for Salesforce applications. This should help teams significantly improve their automated tests because they can reliably document entire test suites and reuse them without the traditional problems that plague Selenium testing. These tests are less likely to be interrupted by UI changes and are easy to maintain throughout the development lifecycle.
Accelerating UI testing is very useful, and the ROI of investing in Selenium testing at the UI level makes it worthwhile. Even with these improvements, testing at the UI remains a bottleneck, and testing business logic at the API level is more efficient.
Test your Salesforce app faster
Fortunately, you can also use Parasoft SOAtest to record the API interactions that are taking place while using Selenic to record UI test scenarios. These records, like UI interactions, can be reused, parameterized, and modified to create API test scenarios.
SOAtest uses AI technology to analyze complex data traffic patterns and locators and condense 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 significantly reduces the overhead of testing, and with some tweaking, API testing can be reduced to the minimal interactions needed to test a particular use case. The following shows a typical workflow for testing Salesforce application apis using SOAtest.
The test API level validates the business logic in the same way as the original UI test case, but the execution time is significantly reduced. As high as 97%. This means that the test suite takes much less time, while also opening up the possibility of extended testing to validate parts of the business logic that are missing at the UI level.
SOAtest API tests are designed to be reused and parameterized as needed. New scenarios are created based on the original records, and data sets created by testers and automatically generated data are added as needed. Now, by extending the test’s data set, you can get a full set of API tests from a simple recording.
By taking advantage of these flexible API tests, we can test more applications because we have effectively eliminated the dependency on the UI for most of our testing. This independence means that tests can be rapidly expanded and run faster in the development plan.
API testing is great, of course, but there are still problems with the test execution environment. There is no enterprise system that does not rely on external services and legacy systems. These are often the bane of the tester because they either completely eliminate testing of production systems, requiring reasonable simulation in the lab, or make integration testing extremely risky. This is where service virtualization becomes critical to decoupling the dependencies of these production systems.
Test your Salesforce application more cheaply
Virtualization services provided by tools such as Parasoft Virtualize are critical to decouple applications under test from complex production environments. Simulated dependency means decoupling the application under test from the production environment.
This provides complete control over data, on-demand deployment, and the ability to parallelize, and greatly speeds up testing without the cost of paying to use apis, test LABS, or interfering with production systems.
Parasoft CTP’s environment manager can draw a test environment for the application under test and set up simulation services as needed. These services can provide real-world responses and support data models that simulate real-world services.
CTP provides a data model for virtualized services and the ability to manage the data sets associated with the data model. The complexity of virtualized services scales according to the needs of the application under test.
Service virtualization makes integration testing easier and cheaper. It also means testing earlier. You can move the API and integration tests further to the left than before.
Most importantly: improve cross-team collaboration
A key advantage of test automation is the ability to collect data and results during test execution. Parasoft DTP aggregates and analyzes data from various test practices used by the team to create a centralized view of quality. In addition, it can correlate these test results to user stories in your requirements management tools, such as Jira.
The ability to “connect the dots” between use cases, test results, code coverage, and overall state is critical to making informed decisions. Teamwork is improved because everyone can see the same source of truth about the application state and can act on the same information as needed.
conclusion
Test automation for Salesforce applications can be cumbersome. UI testing using Selenium is possible, but can be time-consuming without further tool assistance. Parasoft Selenic provides just the assistance needed to make Selenium testing of Salesforce applications practical and improve the results of UI-based testing.
Ui-based testing is important, but it’s an inefficient way to test all of your application’s business logic. API testing accelerates application testing and improves test coverage.
More tests can be done in less time than UI tests. The impact of API testing is further improved through service virtualization, which decouples your Salesforce application from its complex and expensive production environment. The powerful combination of Parasoft SOAtest, Virtualize, and CTP means that testing is more comprehensive and can start early in the development cycle.
Finally, team collaboration is improved by having a centralized view of quality through test automation at all levels of the application. Parasoft DTP provides meaningful insights into sound decision making and improves an organization’s ability to focus on innovation.