End-to-End Salesforce Automation: Lightning Components, a Dynamic DOM, and OTP MFA
Originally published on the CloudQA blog . Salesforce is a genuinely difficult platform to automate well, and the difficulty is structural rather than incidental. Three characteristics of the platform combine to make naive automation approaches fail quickly. The Problem A dynamic DOM. Salesforce's Lightning interface generates much of its markup dynamically, and element attributes — including IDs…
Salesforce can be difficult to automate, due to its dynamic DOM, Lightning components, and OTP-based MFA. A dynamic DOM means that element attributes like IDs and classes can change between sessions or even within a single page. Lightning components render complex UI elements through Salesforce's own internal structure, making them harder to identify and interact with compared to standard web forms.
OTP-based MFA is intentionally resistant to automated bypass, requiring a persistent authenticated session for automated execution.
To overcome these challenges, a stable selector strategy was developed for the dynamic DOM. Rather than relying on single-attribute selectors that break frequently, stable selectors were identified and custom selector strategies were built for elements where they didn't exist. A dedicated Chrome Debugger Profile was used to maintain an already-authenticated Salesforce session, solving OTP/MFA issues more reliably than trying to script around challenges on every execution.
A separate, isolated execution environment was configured to provide a consistent environment for Salesforce test runs. This prevented state bleed from unrelated projects and made it easier to diagnose failures, as the environment itself was a known, controlled variable. Salesforce-specific components, such as dynamic forms, dropdowns, data tables, pop-ups, and Lightning components, required specialized interaction strategies built around their actual behavior, rather than treating them as standard HTML controls.
To maintain stability as Salesforce elements and attributes change, fallback selector strategies were implemented. This allowed the automation to locate the correct element through an alternate identifying property when a primary selector stopped matching. When a selector needed updating, it could be updated directly, without having to re-record the entire test.
With these foundational problems solved, a full end-to-end Salesforce automation suite was built, automating complex business workflows across multiple Salesforce screens. This allowed for complete processes, including navigation, data entry, validation, and record updates, to be automated end-to-end without manual intervention or frequent test rewrites.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.