Pro Tips from the SmartBear Community – Scaling Salesforce Testing with TestComplete 

Pro Tips from the SmartBear Community – Scaling Salesforce Testing with TestComplete 
SmartBear
  June 17, 2025
Foreword  

The following article was written by one of our SmartBear Community Members, Hassan Ballan – Senior Test Automation and QA Specialist and Consultant. In it, he gives expert, real-world guidance for testing Salesforce lightening applications using SmartBear TestComplete – without relying on AI or OCR.  His methodical approach gives developers and testers a reliable framework for navigating the complexities of dynamic Salesforce UI testing – emphasizing precision, performance, and long-term maintainability. 

 TestComplete helps teams automate testing for their most complex applications, including for companies in the public sector and other regulated industries. That’s why we’re proud to share advice from community members, like Hassan, who help other like-minded quality professionals navigate complex testing challenges they may be facing. Read on to learn what he has to say: 

The SmartBear Community is home to thousands of development and test professionals who solve challenges together, share advice, and participate in engaging discussion. Join for free to be a part of the conversation!  

Introduction 

SaaS platforms like Salesforce CRM are frequently patched and updated, making test automation maintenance an ongoing challenge. 

This article presents a proven strategy for automating the Salesforce Lightning Experience using TestComplete, one that supports long-term maintainability and scalability in the face of Salesforce’s rapid UI evolution. 

Scalable Salesforce Lightning Experience Automation Using TestComplete: A Field-Tested Strategy 

All strategies in this article were built using only the TestComplete Web license, without relying on OCR or Al-enhanced capabilities. The approach is designed to be scalable and maintainable using standard features available to most teams.  

We’ll focus on essential techniques such as manual NameMapping control, caching strategies, parameterized XPath selectors, smart waits, and DOM structure analysis. 

Automation in a Rapidly Changing Salesforce Environment  

Salesforce’s UI framework changes frequently. While invisible to end users, these updates often break test automation by altering how elements are recognized.  

Frequent internal deployments (e.g., biweekly sprints with customization) further compound maintenance. Delayed updates blur the line between real UI changes and false test failures, making root-cause analysis difficult. Staying current is key to preserving automation ROI.  

KeywordTests scripts vs. Code Scripts  

While TestComplete supports both code-based and KeywordTests-based scripts, each offers distinct advantages.  

KeywordTests Benefits: 
  • Faster test creation and rearrangement 
  • One-click operation timeout adjustments 
  • Direct run of individual operation 
  • Enables non-coding team members to contribute 
  • Automatic reference update when a NameMapping Alias node name or a script name are changed  
Hybrid Strategy:  

Use keywordTests for UI flows and code scripts for specialized logic, such as:  

  • Date/time calculations 
  • Dynamic value generation (e.g., timestamps) 
  • Browser control (e.g., incognito mode)  

Handling Dynamic Salesforce URLs  

Salesforce URLs include object names, dynamic record Ids, and state indicators, such as: /lightning/r/Account/0011f00000hr5NdAAI/edit/lightning/o/Account/new  

These cause redundant NameMapping entries for the same logical pages.  

Solution: Use wildcard to consolidate NameMapping pages: 
  •  ✔*/lightning.force.com/lightning/* (recommended)  
  • X  * (too broad) 
  • X */lightning.force.com/lightning/o/Account/new* (too narrow)  

Use one generic page reference. Avoid opening multiple tabs with similar URLs. TestComplete may not distinguish them.  

Simplifying Field Mappings  

Salesforce uses consistent UI framework across object. A UI update affecting one field type can impact all instances, requiring extensive remapping.  

Solution and Steps: Use parameterized XPath with persistent variables. 
  1. Add persistent variables on the project level: 
    • LabelText 
    • ItemValue 
  1. Create NameMapping parent/child Alias nodes with parameterized XPath: 
    • PicklistField://div[@part=’combobox’ and descendant::text()=’%LabelText%”] 
    • PicklistButtonDropdown://div[@part=’combobox’ and descendant::text()=’%LabelText%’]/div//*[@role=’combobox’] 
    • Picklistltem://div[@part=’combobox’ and descendant::text()=’% LabelText%’]//span[@title=”%ItemValue%’] 
  1. In your script: 
    • Set the variable values 
    • Refresh the NameMapping cache 
    • Interact with the field 

Handling Shadow DOM in Salesforce  

Salesforce frequently uses Shadow DOM in areas like related lists, dynamically activating different DOM branches.  

Steps to Identify Active Elements: 
  1. In browser DevTools Console:$x(“your XPath here”) 
  2. Expand the results and hover over each to locate the active one visible on-screen (typically the last). 
  3. Right-click → Open in Elements panel and from that panel right click → Copy full XPath 
  4. Compare paths to identify the active DOM branch root element and refine your XPath to include it:$x(“//root XPath//your XPath here”)  

Managing NameMapping at Scale 

In large Salesforce automation project, NameMapping can become unmanageable without discipline.  

Best Practices: 
  • Avoid auto-generated entries (like “record”) 
  • Use one targeted XPath per node 
  • Maintain a clean and consistent hierarchy 
  • Restrict NameMapping edits to a single owner 

Working with Lazy-Loaded Pages 

Salesforce renders elements dynamically as the user scrolls. TestComplete cannot interact with elements that aren’t yet present in the DOM.  

Best Practice: Create a reusable function that: 
  • Scrolls to the bottom of the page, and wait for page to load 
  • Scrolls back to the top of the page, and wait for page to load  

This ensures the page is fully rendered before interaction.  

Refreshing NameMapping Cache  

TestComplete caches object mappings to improve speed, but this can cause issues with generic URLs and parameterized selectors.  

Fix: After navigation or variable value change, call:  Aliases.browser.RefreshMappingInfo()  

Automate this into a helper function and to avoid inconsistencies, call it on each page load and variable value change.  

Smart Waiting Strategy  

Speed matters, but stability matters more. Avoid fixed delays by using a smart, layered waiting strategy.  

Best Practices: 
  1. Wait for page load and increase operation-level default timeout (e.g., 60 seconds) 
  2. Check object properties in sequence: 
    • Exists 
    • Enabled 
    • VisibleOnScreen
  3. For toggle buttons (e.g., Save): 
    • Wait for Enabled = false 
    • Then wait for Enabled = true  

Conclusion & Pro Tip  

This strategy has sustained an automation project across five years of continuous testing in a live Salesforce environment with frequent agile deployments. 

It Emphasizes: 
  • Manual NameMapping control 
  • XPath expertise 
  • Shadow DOM navigation  

While it limits the use of TestComplete’s out-of-the-box features (e.g., self-healing, auto- mapping), it creates a scalable, stable, and maintainable automation framework for a dynamic platform like Salesforce. 

Pro Tip: Maintain a separate TestComplete project for exploratory test recordings and quick trials. Only manually integrate stable, reviewed logic into the main framework.  

Summary 

While this approach may slow initial script creation, it significantly reduces long-term maintenance. By moving beyond default behaviors and embracing a structured methodology, you build a resilient automation suite that thrives in the face of constant Salesforce changes. 

For teams automating complex SaaS platforms, this strategy delivers the stability, visibility, and adaptability required for lasting success. 

Closing Word 

Thank you to Hassan for your contribution, this type of advice is exactly why we are proud to support a vast community of professionals. If you enjoyed this article and are curious to read more from Hassan or other community members, be sure to check out and sign up for the SmartBear Community. If you are interested in hearing how other customers have used TestComplete to test Salesforce – check out this case study!

You Might Also Like