Blog
Salesforce UI Test Automation: Build Tests That Last

Rishabh Kumar
Published on

Table of contents
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Lorem ipsum
Salesforce is a web application, so in theory any web automation tool can test it. In practice, Salesforce is where UI automation suites go to die. IDs change on every page load, components hide inside shadow roots, the same page looks different for every profile, and three times a year Salesforce changes the platform underneath you.
This guide explains exactly why Salesforce UI automation is hard, compares the approaches available, and shows how to build tests that survive Lightning, profiles, Experience Cloud and every seasonal release.
What is Salesforce UI Test Automation?
Salesforce UI test automation is the automated testing of Salesforce through its user interface, such as Lightning Experience, Experience Cloud sites and the service console, by driving a real browser through business processes as real users and checking the results. It proves that people can still do their jobs after configuration changes, deployments and Salesforce’s own releases.
It complements, rather than replaces, Salesforce’s own testing layers. Apex tests check code, Flow tests check automation logic, and UI tests check that a sales rep, agent or customer can actually complete the journey.
For the full picture of testing Salesforce, from unit tests to UAT, start with our guide to Salesforce testing.
Which Salesforce Interfaces You’ll Need to Test
Interface | Who Uses It | What’s Different for Testing |
|---|---|---|
Lightning Experience | Internal staff, such as sales and service teams | Lightning Web Components, dynamic pages and record pages that vary by profile and record type |
Service Console and console apps | Contact centre agents | Workspace tabs and subtabs, the utility bar and several records open at once |
Experience Cloud sites | Customers and partners | Separate sign-in, site themes and publishes that change independently of the org |
Salesforce Classic and Visualforce pages | Older orgs and legacy pages | Visualforce often renders inside iFrames within Lightning |
Mobile web and the Salesforce mobile app | Field and mobile users | Mobile layouts in the browser, and a native app that needs mobile tooling |
Most orgs use more than one of these. Your automation needs to cover each one your users rely on, not just the Lightning record pages admins see.
Why Salesforce UI Automation Breaks So Often
Challenge | What Happens to Tests | What Works |
|---|---|---|
Dynamic IDs | Generated IDs such as “input-123” change between sessions | Locate by field label, button text and context |
Lightning Web Components and shadow DOM | Ordinary selectors can’t see inside components | Shadow-aware locators, or label-based steps |
Synthetic to native shadow migration | Internal structure changes under existing tests | Avoid tests that depend on component internals |
Visualforce and embedded content in iFrames | Elements sit in a separate document | Switch frames deliberately |
Profiles, permission sets and record types | The same page shows different fields to different users | Test each journey as each persona |
Dynamic Forms and conditional visibility | Fields appear and disappear based on data | Assert visibility rules explicitly |
Lazy loading and asynchronous rendering | Elements arrive after the page appears ready | Wait for conditions, never fixed time |
Three releases a year | Platform changes break tests nobody touched | Run the suite in every sandbox preview window |
To understand in detail how Lightning components hide elements, and how to reach them, read our guide to Salesforce LWC testing.
Salesforce’s Own Testing Layers, and the Gaps They Leave
Layer | Tests | Doesn’t Test |
|---|---|---|
Apex unit tests | Server-side code, with the coverage Salesforce requires to deploy | What users see or do |
Flow tests | Record-triggered flow logic | Screen flows end to end, or the UI around them |
UTAM (UI Test Automation Model) | UI tests through page objects that Salesforce maintains for base components | Your business process unless you build it, and you maintain your own page objects |
Agentforce Testing Center | Agent topics, actions and responses | The surrounding UI journeys and connected systems |
DevOps Center testing | Runs test suites and quality gates on promotions | Changes that don’t pass through the pipeline, such as Salesforce releases |
UI automation fills the gap all of these leave, real users completing real processes, across clouds and connected systems.
Four Approaches to Salesforce UI Automation, Compared
Approach | How It Works | Strengths | Watch For |
|---|---|---|---|
Coded frameworks (Selenium, Playwright) | Engineers write tests in code | Free, flexible, fits developer workflows | Heavy maintenance against dynamic IDs, shadow DOM and releases |
UTAM with a framework | Page objects for Salesforce base components, used from code | Salesforce-maintained objects for standard components | Engineering effort, and custom components need your own objects |
Salesforce-focused test tools | Tools built around Salesforce metadata and components | Understand Salesforce structures | Check coverage of journeys that leave Salesforce |
AI-native, plain English platforms | Tests written as steps users would describe, with AI-assisted maintenance | Readable by admins and business analysts, lower maintenance | Check how AI changes are reviewed and recorded |
For a side-by-side look at the tools themselves, see our guide to choosing the best Salesforce test automation tools.
How to Write Locators That Survive Salesforce Changes
The single most important rule is to find fields the way a user does, by their label, never by generated IDs or deep CSS paths.
TypeScript (Playwright)
Java (Selenium 4)
Watch for duplicate labels. The same label can appear in a record page, a related list and a modal at once, so scope locators to the section or dialog you mean.
For the traps inside web components, including XPath and slotted content, see shadow DOM testing.
Handling Lightning Components That Trip Up Tests
Component | What Goes Wrong | What Works |
|---|---|---|
Toast messages | They disappear after a few seconds, before the test checks them | Check for the toast immediately after the action, or check the saved record instead |
Modals for new and edit | Fields with the same label exist on the page behind the modal | Scope locators to the open dialog |
Comboboxes and picklists | They aren’t native dropdowns, so select-style commands fail | Click to open, then choose the option by its visible text |
Lookup fields | Search results load asynchronously, and similar records match | Type a distinctive value and wait for the exact result |
Related lists | Items load lazily, and the list may need “View All” | Wait for the list, or open the related list page |
Path component | Stages change by record type and sales process | Choose stages by label, and test each record type |
Dynamic Forms and conditional fields | Fields appear only when conditions are met | Set the condition, then assert the field appears or stays hidden |
Console tabs and subtabs | Several records open at once, and focus shifts | Work within the focused tab, and close tabs after each test |
Most of these are about timing and scope. Wait for the specific thing you need, and narrow every locator to the part of the page you mean.
Test Every Journey as Each Persona, Not as an Admin
A test run as a System Administrator proves almost nothing about what a sales rep or service agent sees. Create a test user per persona in each sandbox, with realistic profiles and permission sets, and run the same journey as each.
Worked example (illustrative)
One “close an opportunity” journey, run as four personas.
Persona | Expected Result |
|---|---|
Sales rep | Can move the stage to Closed Won, but cannot edit the discount above 10% |
Sales manager | Can approve the discount and close the deal |
Finance user | Sees the opportunity read-only, with the invoice fields visible |
Partner user (Experience Cloud) | Sees only their own deals, with internal fields hidden |
Four runs of one journey catch the permission defects that a single admin run would miss entirely.
For signing in as each persona securely, including MFA and SSO, read handling Salesforce login, MFA and SSO in automated tests.
A Complete Salesforce Journey, Worked Through
Here’s how a team automates one of its most important processes, lead to closed deal, across personas and systems.
Plain English (illustrative)
The journey checks the happy path, a validation rule, an approval routed to the right person, and access rules for two personas. A final API step can then confirm that the closed deal created an order in the connected ERP.
Create Salesforce Test Data Through the API, Not the UI
Creating accounts, contacts and opportunities through the UI before every test is slow and fragile. Create them through the Salesforce REST API in a setup step, run the UI journey, then clean up. Keep the UI for the steps users actually perform.
TypeScript (Playwright request, illustrative)
Use a dedicated integration user with only the permissions it needs, keep tokens in your pipeline’s secret store, and replace “vXX.0” with the API version your org supports. Records created this way are fast to set up and easy to clean up, and they keep UI tests focused on what users actually do.
Testing Journeys That Leave Salesforce for Other Systems
Real processes rarely stay inside one cloud. A quote may start in Sales Cloud, move through CPQ, create an order in an ERP and trigger a case in Service Cloud. Test the journey end to end, through every system it touches, and check the data at each step.
Testing Screen Flows Through the UI
Flow tests in Salesforce check the logic of record-triggered flows, but screen flows are what users actually see. Test them as journeys, covering each path through the flow, the validation on each screen, the back and next buttons, and the records the flow creates or updates at the end. Screen flows often change more often than code, because admins can edit them directly, so they deserve a place in every regression run.
Testing Experience Cloud Portals as External Users
Customer and partner portals change independently of the internal org, through site publishes and theme changes. Test them as external users, with their own sign-in flows, at mobile widths, and after every site publish as well as every Salesforce release.
How to Release-Proof Your Suite for Every Salesforce Release
Keep a preview sandbox: Make sure at least one sandbox gets each release early.
Run the full UI suite the day it upgrades, as every persona.
Classify failures into platform changes, your configuration and test issues.
Check release updates that change behaviour, and test them before they’re enforced.
Run a smoke set in production after the upgrade weekend.
For the dates that set each release window, from sandbox preview to production weekends, see the Salesforce release cycle, and for enforced behaviour changes, testing Salesforce release updates.
Running Salesforce UI Tests in Your Pipeline
Trigger | What Runs | Why |
|---|---|---|
Every deployment to a sandbox | Journeys touching the changed metadata | Catch regressions from your own changes |
Nightly | The full UI regression suite, as every persona | Breadth, and early warning of environment drift |
Sandbox preview upgrade day | The full suite on the preview sandbox | Find what Salesforce’s release changed, before production |
Production upgrade weekend | A small smoke set | Confirm the release landed safely |
Site publish | Experience Cloud journeys | Catch theme and layout changes |
Whether you deploy with DevOps Center, Salesforce CLI or a third-party tool, the pattern is the same. Trigger UI journeys after each deployment and on Salesforce’s release calendar, because both can break things.
For how DevOps Center’s quality gates work, and what they leave to you, read about Salesforce DevOps Center testing.
Common Salesforce UI Automation Mistakes
Testing only as a System Administrator, which hides every permission defect.
Using IDs copied from the browser, which change on the next page load.
Creating data through the UI in every test, which makes suites slow and fragile.
Skipping the preview window, so release problems surface in production.
Ignoring Experience Cloud, where customers see problems first.
Treating every failure as a broken test, instead of checking whether Salesforce or the configuration changed.
A 10-Point Salesforce UI Automation Checklist
Fields are located by label and context, never generated IDs
Shadow DOM and iFrames are handled deliberately
Duplicate labels are scoped to the right section
Every journey runs as each persona that uses it
Test data is created and cleaned up through the API
Dynamic Forms and visibility rules are asserted, not assumed
Journeys follow processes into connected systems
Experience Cloud sites are tested as external users
The suite runs in every sandbox preview window
Failures are classified before anyone fixes a test
Salesforce UI Test Automation With Virtuoso QA
Virtuoso QA lets admins, analysts and testers write Salesforce journeys in plain English, finding fields by their visible labels, with enhanced element selection for Salesforce built in. Other selectors are kept as fallbacks, including a JS path for shadow DOM, and Live Authoring shows straight away if a step can’t find its field.
Journeys run as each persona’s own test user, with sign-in built once per persona as a reusable step, and environments hold the settings for each sandbox. API and database steps create data and check outcomes, and a journey can follow a process from Salesforce into other web applications. Runs can be scheduled or triggered from CI/CD on the day a sandbox upgrades.
When something fails, Touchstone classifies it as an application defect, test brittleness, an environment problem, data or configuration drift, and proposes repairs only for brittleness, for a named person to approve.
💡Virtuoso QA’s Salesforce test automation runs your Salesforce journeys in plain English, as every persona, across Lightning, Experience Cloud and connected systems, in every sandbox preview.
Related Reads
Salesforce UI Test Automation FAQs
Why do Salesforce UI tests break so often?
Can Selenium test Salesforce Lightning?
What is UTAM?
Should Salesforce UI tests run as an administrator?
When should Salesforce UI tests run?
How do you test Salesforce Lightning modals and toasts?
Written by

Rishabh Kumar
AI Testing & Quality Engineering Contributor
Rishabh leads business development and marketing at Virtuoso QA. He writes about AI-powered test automation, end-to-end testing, self-healing tests, and quality engineering, exploring how these capabilities can improve test coverage, reduce test maintenance, and support reliable software releases.









