Salesforce

Handling Salesforce Login, MFA and SSO in Automated Tests

Rishabh Kumar

Published On

Handling Salesforce Login, MFA and SSO in Automated Tests
eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image
eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image
eBook CTA Background
RECOMMENDED RESOURCES
Ebook image

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

eBook CTA Background
RECOMMENDED RESOURCES

Salesforce testing: Complex Element Selection Best Practice

While some applications are easy to automate, others, like Salesforce, need a little extra love and attention. This is our best practice guide to complex element selection.

Get the eBook →

Ebook image

Table of contents

Lorem ipsum

Lorem ipsum

Lorem ipsum

Lorem ipsum

Lorem ipsum

How Do You Handle Salesforce Login and MFA in Automated Tests?

Automated tests need to log in to Salesforce as real personas without weakening security. Give each persona a dedicated test user. Satisfy multi-factor authentication with a time-based one-time password generated from a secret kept in a vault. Test single sign-on through your identity provider's test tenant. And treat login as a monitored step of its own, so a broken login is diagnosed in seconds instead of looking like a hundred failed journeys.

One warning before anything else. Salesforce has tightened MFA enforcement several times, and the exemptions teams used to lean on for test accounts are narrowing. Check your org's current status before designing around one.



What Salesforce's MFA Rules Mean for Test Accounts

Salesforce made multi-factor authentication a contractual requirement for customers from 1 February 2022, then switched it on and enforced it for direct logins to its products. From the start, its guidance listed some accounts as exempt, including accounts used by test automation tools and robotic process automation. Admins exempted them with a permission called Waive Multi-Factor Authentication for Exempt Users.

The picture has since tightened. Guidance published in 2026 by identity and AppExchange partners describes Salesforce enforcing MFA for single sign-on logins as well as direct ones, and requiring phishing-resistant MFA for privileged users, such as system administrators and users with permissions like Modify All Data. Partners also report that the waiver permission no longer exempts accounts automatically once that enforcement reaches an org, and that exceptions for automation accounts may need Salesforce Support’s approval.

In practice, that leaves four rules.

  • Don’t build a test strategy that depends on an exemption. It may not be available, and it may be withdrawn.

  • Don’t run tests as privileged users. It’s poor testing practice anyway, and privileged accounts face the strictest requirements.

  • Satisfy MFA properly, using the patterns below.

  • Check your own org’s status with Salesforce Help and your account team before each release, because enforcement rolls out over time.



Patterns for Login, MFA and SSO

Pattern

How it works

When to use it

Watch out for

Dedicated test users per persona

Each persona has its own test user in each sandbox, with realistic permissions and no admin rights

Always. It’s the foundation of persona testing.

Licence cost per user, and keeping users in step across sandboxes after refreshes

Time-based one-time passwords (TOTP)

Register an authenticator for the test user and keep its secret in a vault. The test generates the current code at login, just as an authenticator app would.

Direct logins where MFA is enforced

Treat the secret as a credential. Vault it, rotate it and restrict who can read it.

SSO through a test identity provider

Test users live in a non-production tenant of your identity provider, which performs MFA and hands the result to Salesforce

Orgs where real users log in through SSO, which is most enterprises

IdP policies and claims must match production, or tests prove a login path nobody uses

Experience Cloud logins

Customer and partner test users log in through the site’s own login page, or external identity providers

Portal and community journeys

Site login flows and self-registration change independently of the internal org

Session reuse within a run

Log in once per persona per run, then reuse the session across journeys

Long suites, to cut login traffic and flakiness

Never share sessions across personas, or access tests become meaningless

Two rules sit across all of them. Credentials and MFA secrets never live in test scripts or repositories. And login is a test step in its own right, reported separately, so a login failure stops the run with a clear reason.

The login screen deserves tests of its own, beyond simply getting in. Lockouts, sessions and error handling are all in login page test cases.



The Changes That Break Every Test at Once

Authentication changes more often than most teams expect, and when it does, every journey fails together.

  • MFA enforcement reaching your org: Tests that relied on an exemption suddenly meet a verification prompt.

  • Retired login methods: Winter ‘27 retired the OAuth username-password flow, so any test harness or integration that got tokens with a username, password and security token stopped working on upgrade weekend.

  • My Domain and URL changes: Winter ‘27 also enforced My Domain URLs in place of hard-coded instance URLs, breaking tests and tools pointed at old addresses.

  • Sandbox refreshes: A refresh can reset test users’ emails, passwords and registered authenticators, and add sandbox suffixes to usernames.

  • Identity provider changes: Certificate rotations, new conditional access rules or changed claims break SSO for test users, often before anyone notices for real users.

  • Session and network policies: New login IP ranges, session timeouts or device activation rules interrupt tests running from cloud pipelines with changing IP addresses.


A Five-minute Login Check for Every Release

Run this at the start of every sandbox preview window, and after every sandbox refresh.

  1. Sign in as each persona, through the same route real users take.

  2. Confirm MFA completes without manual help.

  3. Confirm the landing page is the one each persona expects.

  4. Confirm any integration that authenticates to Salesforce can still get a token.

  5. Note anything that changed, and check the release notes and Release Updates page for the cause.

If any of these fail, stop and fix login before running anything else. Every other failure in the run will be noise.

This check works best when you know exactly when each sandbox upgrades. The dates are set out in Salesforce release cycle.



How Virtuoso QA Handles Salesforce Login

In Virtuoso QA, login is built once per persona as a reusable library checkpoint, so when authentication changes, it’s fixed in one place rather than in every journey. Journeys run as that persona’s own test user, which means authentication and access get tested together.

Environments hold the URLs and settings for each sandbox, so a My Domain change is updated once. And when login fails, the run fails at the login step and says so.

Every identity setup is a little different, so talk to us about your identity provider and MFA method when planning test users.

Virtuoso QA's Salesforce test automation builds each persona's login as one reusable step, keeps every sandbox's settings in one place, and stops the run at the login step when authentication changes.



Related Reads

Frequently Asked Questions

Do Automated Test Accounts Need MFA in Salesforce?

How Do You Automate Salesforce Login with MFA?

How Do You Test Salesforce Single Sign-on?

Why Did All My Salesforce Tests Fail at Once After a Release?

Should Test Users Have Administrator Rights?

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.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

See what your next release looks like with Virtuoso

Book a walkthrough on your applications and your workflows. Bring a requirement, a user journey, or a brittle Selenium script, and watch the loop run on something you recognise.

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Virtuoso QA is establishing the standard of proof for software releases. Its governed QA loop turns business requirements into tests for any browser-based application: AI proposes, a deterministic engine executes, a person approves what matters, and every decision leaves evidence.

Trust Center

AICPA

SOC

WAVE STRONG PERFORMER

@ Copyright 2026 SpotQA, Creators of Virtuoso QA

Platform

Solutions

Resources

Platform

Solutions

Resources

Platform

Solutions

Resources