Salesforce Test Automation Challenges and How to Handle Them
Salesforce test automation is hard for seven recurring reasons: three platform releases a year, Lightning components that hide their markup in a shadow DOM, element IDs that change on every page load, sandboxes that drift from production, Flow logic that has no visible screen, Apex coverage rules that reward quantity over quality, and permissions that change what each user sees.
None of these is a reason to stop automating. Each has a known workaround, and most teams that struggle are fighting two or three of them at once without naming them. This guide names all seven, shows what each one breaks, and gives the fix. It sits alongside our broader guide to salesforce test automation, which covers strategy and setup; this one is for teams whose suite already exists and keeps failing.
What are the main Salesforce test automation challenges?
Here is the whole list in one place, so you can jump to the problems you recognize. Each fix works with any tool, and where it helps we note how Test Studio handles the same problem.
Challenge | What breaks | How to handle it |
|---|
Seasonal releases | UI tests fail after Salesforce upgrades your org | Test on a preview sandbox before each release reaches production |
Shadow DOM | XPath and some CSS selectors cannot see inside Lightning components | Use tools and locators that reach into shadow trees |
Generated IDs | Recorded tests fail on the next page load | Find fields by label and role, never by ID |
Sandbox data drift | Tests pass in a sandbox and fail in another, or after a refresh | Create test data inside each test, and pick the right sandbox type |
Flow and automation logic | Business rules break with no visible UI change | Add Flow tests and API checks below the UI |
Apex coverage pressure | Code reaches 75% coverage with tests that assert nothing | Review Apex tests for assertions, not only coverage |
Profiles and permissions | A test passes as an admin and fails for real users | Run key journeys as each main persona |
The sections below take each one in turn, starting with the one that causes the most failures.
How do seasonal releases break Salesforce tests?
Seasonal releases break tests because Salesforce changes your org on its schedule, not yours. Salesforce ships three major releases a year, Spring, Summer, and Winter, and each one can change page layouts, component markup, and default behavior in Lightning Experience.
The useful part is the warning window. According to Salesforce, the sandbox preview starts about four to six weeks before the production upgrade, for sandboxes on preview instances. A sandbox's instance depends on when it was last refreshed, and refreshing during the preview period moves it to a non-preview instance. So the fix is partly technical and partly calendar discipline:

Keep at least one sandbox on a preview instance, and do not refresh it after the preview cutoff date.
When preview starts, run the full suite there and compare the results with a run on a non-preview sandbox.
Sort the new failures into three groups: real defects in your customizations, intended Salesforce changes that need test updates, and tests that were already fragile.
Fix and rerun before the production upgrade date, then run the smoke suite in production right after it.
This is salesforce regression testing at its most predictable: you know when the change is coming, and you get weeks of notice. The general method for choosing and scheduling a regression suite is the same as anywhere, and our guide on how to automate regression testing covers it. Wire the preview run into your pipeline too, so a failure blocks the deployment instead of waiting in a report; our guide to CI/CD quality gates shows how.
Why do Lightning pages defeat recorded locators?
Lightning pages defeat recorded locators for two reasons that often arrive together: components wrap their markup in a shadow DOM, and many element IDs are generated fresh on each page load.
We built a small page that mimics both: a custom component with an open shadow root holding an "Amount" field whose ID changes on every load. Then we ran three versions of the same step on Playwright 1.63.
TYPESCRIPT
import { test, expect } from '@playwright/test';
test('recorded ID', async ({ page }) => {
await page.goto('/');
await page.locator('#input-4821').fill('5000', { timeout: 3000 });
});
test('XPath', async ({ page }) => {
await page.goto('/');
await page.locator('//input[@name="amount"]').fill('5000', { timeout: 3000 });
});
test('label and role', async ({ page }) => {
await page.goto('/');
await page.getByLabel('Amount').fill('5000');
await page.getByRole('button', { name: 'Save' }).click();
await expect(page.getByRole('status')).toHaveText('Saved 5000');
});
The results:
Recorded ID failed. The ID from an earlier page load no longer existed.
XPath failed. The field sits inside a shadow root, and Playwright's locator guide notes that XPath does not pierce shadow roots, while its other locators do.
Label and role passed. The test found the field the way a user does, by its visible label, filled it, saved, and checked the result.

Two lessons follow. First, avoid any locator built from an ID you saw in a recording. Second, check that your tool reaches inside shadow trees; tools differ here, and some need extra steps for each component. Salesforce's own answer is UTAM, a page object model written in JSON that handles shadow DOM, and Salesforce says it plans to deliver UTAM page objects for each release. The wider causes of fragile browser tests are covered in our article on automated UI testing.
How do you keep sandbox data from breaking tests?
Keep sandbox data from breaking tests by making each test create the records it needs, and by matching the sandbox type to the kind of testing you do. Salesforce's sandbox types differ sharply in data and refresh rules:
Sandbox type | Data copied | Refresh interval | Good for |
|---|
Developer | Metadata only | Once a day | Unit tests, Flow tests, and building automation |
Developer Pro | Metadata only, more storage | Once a day | Larger seeded data sets |
Partial Copy | Metadata plus a sample of production data | Every 5 days | Integration and UI regression runs |
Full Copy | Metadata and all production data | Every 29 days | Release rehearsal and performance checks |
Those figures come from Salesforce's sandbox guide. The 29-day limit on Full Copy sandboxes is the one that catches teams out: a test that depends on a particular account existing will break after the next refresh, and you cannot refresh again for a month.
Three habits remove most data failures:
Create records through the API at the start of each test. Then delete them at the end, or tag them for a nightly cleanup job.
Never share a test user between parallel tests. Two tests editing the same opportunity will collide.
Store credentials as secrets. Keep sandbox usernames and passwords out of test code and out of logs, because sandboxes copied from production can hold real data.
How do you test Flow and other automation with no screen?
Test Flow and other declarative automation below the UI, because a record-triggered flow can change a dozen fields without anything visible changing on screen. A UI test that only checks the page will miss it.
Salesforce supports flow tests in Flow Builder for record-triggered flows. You set a triggering record, add assertions on decision outcomes and field values, and run the test from the flow. Each test covers either a created or an updated record, not both, and the triggering records are simulated rather than saved to the org.
Flow tests check the flow in isolation. To check the whole chain, add API checks: create or update a record over the REST or SOAP API, then read it back and assert on the fields your automation should have set. That catches problems where two automations interact, such as a flow and an Apex trigger on the same object, which neither one's own tests will show.
Is 75% Apex code coverage a trap?
It can be. Salesforce blocks deployment when coverage falls short: its code coverage guidance says a deployment fails if the average coverage of new and existing code does not meet the 75% threshold. That rule is useful, but it measures lines run, not behavior checked.
The trap is a test that calls a method and asserts nothing. It adds coverage, passes every time, and catches no bugs. Under deadline pressure, these tests multiply.
Handle it in review rather than in tooling:
Require at least one meaningful assertion per Apex test method. Check the result, not only that no error was thrown.
Test bulk behavior. Insert many records at once, because triggers that pass with one record can hit governor limits with many.
Test as a restricted user. Run key tests as a user without admin rights, so sharing and permission bugs surface.
Apex tests protect your code. They do not check that the Lightning pages your users see still work, so they complement UI and API tests rather than replacing them.
Why does a test pass for an admin and fail for real users?
A test passes for an admin and fails for real users because profiles, permission sets, and record types change what each user can see and do. Admin users see every field and button. A sales rep may not see the field your test fills in, or may get a different page layout entirely.
The fix is simple to state: run your most important journeys as each main persona, such as a sales rep, a service agent, and a manager, not as a system administrator. Keep one test user per persona in each sandbox, with the same permission sets as production, and log in as that user at the start of the test. When a release changes a permission default, these tests are the ones that catch it.
Which tests belong at which layer?
Most of the challenges above get easier when each kind of test lives at the right layer. Here is a working split for a typical Salesforce org:

Layer | What it checks | Typical tool | When it runs |
|---|
Apex unit tests | Triggers, classes, and bulk behavior | Salesforce's Apex test framework | Every deployment |
Lightning web component tests | Component logic in isolation | Jest, through Salesforce's LWC tooling | Every commit to component code |
Flow tests | Decision paths and field updates in record-triggered flows | Flow Builder | Every change to a flow |
API checks | Records, automation chains, and integrations | REST or SOAP API calls | Every merge |
UI journeys | What users see in Lightning, by persona | A browser automation tool | Every merge (smoke) and every release preview (full) |
The UI layer should be the smallest, because it is the slowest and the most affected by seasonal releases. If most of your suite lives there today, moving checks down to the API and Flow layers is usually the fastest way to a calmer release season.
The layer changes the tool, not the work. Each layer still needs test design, test case creation, test automation, test execution, and QA reporting and analysis, and the UI layer carries most of the test maintenance and optimization after every seasonal release. Budget for that step first, because it is the one Salesforce schedules for you.
Which tools handle these challenges best?
The tools that handle test automation for Salesforce best reach into shadow DOM without extra work, find elements by label and role, and run UI and API checks in the same suite. Before you shortlist, test each tool on your own org during a preview window; that is where the differences show.
Options range from open-source frameworks with UTAM page objects to commercial platforms such as Tricentis Tosca, which many enterprises use for Salesforce and SAP together. Our comparison of salesforce testing tools goes tool by tool, and our wider guide to regression testing tools explains how to run a fair two-week trial. If your admins and testers do not write code, put the same shadow DOM test to the codeless test automation tools on your list.
If you need the suite running before the next release and your team has no spare capacity, our forward deployed engineers work inside your team on hard environments like Salesforce, each carrying a Test Studio license, and are measured on a baseline agreed in writing in week one. Talk to the team about your release calendar. If you would rather hand over the testing function entirely, our outsourced QA service runs it while the suite and sign-off stay with you.
Can one approach cover Salesforce and SAP?
Yes, and many enterprises need it, because a quote created in Salesforce often becomes a sales order in SAP. The release problems rhyme: Salesforce upgrades three times a year, and SAP's cloud edition upgrades twice. Our guide to SAP S/4HANA testing covers the SAP side of that calendar.
The practical requirement is a suite that can drive a browser for Lightning, a desktop for SAP GUI, and APIs for both, which is why desktop application testing matters as much as browser coverage in these estates. Whether you choose one tool or two, the same rules apply: find elements by what users see, keep data inside each test, and test on preview systems before upgrades. Our overview of SAP test automation covers strategy, and the articles on choosing an SAP test automation framework and comparing SAP testing tools go deeper.
How does Test Studio handle Salesforce testing?
Test Studio, our AI test automation platform, was built for the kind of mixed estate described above.
UI and API in one suite. Test Studio runs Lightning UI flows in the browser and API checks over REST and SOAP in the same suite, so a Flow's effect can be checked through the API in the same run as the screen that triggered it.
Credentials kept out of sight. Sandbox credentials are stored as masked secret variables.
Release changes as reviewable diffs. When a seasonal release changes the UI, Test Studio proposes the fix as a diff your team approves.
Tests that follow the release. Tests are versioned with the release branch.
More than Salesforce. Windows and macOS desktop applications and database checks run in the same suite, for estates that include SAP GUI or other desktop apps.
Runs from your pipeline. Test Studio runs on CLI nodes you control and connects to GitHub and Jira; see the full list of integrations.
Flat price. Test Studio is $220 per seat per month, with no metering on test runs. Details are on the pricing page.
Run a Lightning journey and its API checks together before the next seasonal release. Book a demo on your own sandbox, or download the solution brief for your team.
For a wider change, such as rebuilding how releases move from sandbox to production across several platforms, our AI SDLC transformation maps where the hours go, rebuilds the steps that delay the release, and transfers the capability back to your team.
Frequently asked questions
How often does Salesforce release updates?
Salesforce ships three major releases a year: Spring, Summer, and Winter. Sandboxes on preview instances get each release about four to six weeks before production, which is the window for running your regression suite. Smaller patches arrive between major releases, so keep a short smoke suite running after any platform change.
Talk to the team about planning tests around release previews →
Can Selenium automate Salesforce Lightning?
Yes, with extra work. Lightning components often place fields inside shadow roots, and many element IDs change on every page load, so recorded Selenium locators break quickly. Teams that succeed use shadow root access, locators based on labels, or Salesforce's UTAM page objects, and keep the UI suite small by testing logic through the API.
Book a demo to see Lightning tests that find fields by label →
Why do Salesforce tests fail after a seasonal release?
Most failures come from changed component markup, moved fields, or new defaults in Lightning Experience, which break locators and assumptions in UI tests. Some are real defects in your customizations exposed by platform changes. Running the suite on a preview sandbox weeks before the upgrade separates the two while there is still time to fix them.
Book a demo to see release changes arrive as diffs for review →
Is 75% Apex code coverage enough?
It is enough to deploy, because Salesforce requires 75% average coverage. It is not enough to prove quality, since coverage counts lines run, not results checked. A test with no assertions adds coverage and catches nothing. Review Apex tests for meaningful assertions, bulk record handling, and runs as restricted users.
Talk to the team about reviewing your Apex test quality →
Which sandbox should you use for automated testing?
Use Developer sandboxes for Apex, Flow, and component tests, because they refresh daily and hold metadata only. Use a Partial Copy sandbox for UI and integration regression runs with realistic data. Save the Full Copy sandbox, which refreshes only every 29 days, for release rehearsals and performance checks.
Download the solution brief to see how Test Studio handles sandbox credentials →
Can you automate Salesforce testing without code?
Partly. Flow tests are built in Flow Builder without code, and several platforms let testers build UI and API tests from plain language or recorded steps. Apex tests still need code. Whatever the approach, check that a no-code tool copes with shadow DOM and changing IDs on your own org before you commit.
Book a demo to see Salesforce tests written in plain English →