
Why UI Tests Need to Log In
Without a way to sign in, TestSprite can only explore and test what a signed-out visitor sees. You configure login once, and TestSprite signs in the same way for feature exploration, test generation, and every run.Getting Started: Sign-in required
The sign-in section has two tabs. Choose No sign-in if the part of your app you want covered works without an account. Choose Sign-in required and three login methods appear as cards; pick the one that matches how users get into your app.
Method 1: Existing Test Account
You give TestSprite a username and password for an account you control. It signs in with them before exploring and before every run.
Configuration
Select Test account credentials
Enter the credentials
Continue
Best for
- Standard email/username + password logins
- A dedicated test account you keep in a known state
- Staging environments with seeded accounts
Limitations
- Doesn’t handle one-time codes. If your login sends an email or SMS code after the password step, this method gets stuck at the code prompt. Use Method 2.
- Doesn’t handle SSO or social login. “Continue with Google” and similar logins can’t be driven with a username and password. Use Method 3.
Method 2: OTP (One-Time Password) Login
For apps that email or text a one-time code at signup or login. You provide nothing: TestSprite registers a dedicated test account with an email address and phone number it owns, receives the code your app sends, and enters it automatically.
Configuration
Select OTP (one-time password) Login
Choose how your app verifies (Verify via)
Create the project
Best for
- Passwordless logins
- Signups that require email verification before you can proceed
- Two-factor flows where a code is the second factor
Limitations
- One managed account per environment. To test with a second managed account, add another environment.
- OTP logins in one environment run one at a time, so the managed inbox or phone doesn’t pick up the wrong code. A second login waits for the first, then reuses its session. This is why session reuse matters most for this method.
- It depends on your signup and login flow. It works wherever TestSprite’s testing agent can drive registration and code entry. If a flow can’t be completed (unusual signup gates, required fields it can’t guess, aggressive bot protection), the login fails loudly rather than running signed out. See Troubleshooting.
Method 3: SSO (Single Sign-On)
For SSO and social logins such as “Sign in with Google”, and for any login that blocks automated sign-in. TestSprite doesn’t automate these. Instead, it opens a real browser, you sign in yourself, and TestSprite records the session so later runs start signed in.
How it works
When you finish creating the project (or click “Log in” from environment settings later), a live browser opens inside the modal. You sign in as usual (for example, click “Continue with Google” and complete Google’s sign-in), then click I’ve finished logging in. TestSprite captures the signed-in session (cookies and local storage) to replay later.
Configuration
Select SSO (single sign-on)
Finish creating the project
Sign in yourself in the live browser
Click I've finished logging in
Best for
- SSO and social logins, such as “Sign in with Google” (“Continue with Google”)
- Logins that block automated sign-in, for example with a CAPTCHA or bot detection
- Any sign-in that’s better completed by a human once than automated
Limitations
- Sessions expire. Your app’s own session lifetime is the ceiling. After that, log in again once (see Re-authenticating).
- It needs a human at capture time, once per session.
Prerequisites
- Your environment has a public URL the live browser can reach. Local URLs (
localhost, private IPs) can’t be reached from TestSprite’s browser.
Reusing a Login Session
Instead of signing in before every test, TestSprite can reuse a recent successful login. On the environment form (for OTP and manual-login environments), turn on Reuse Login Session and set a Reuse window in minutes. Within the window, runs start from the signed-in session; after it, TestSprite logs in fresh.
Multiple Test Accounts, Multiple Environments
Each account is one environment, and a project can have several. That’s how you cover different roles (admin vs. member) or tenants (org A vs. org B).
Adding Another Environment
Open the project's environments
Click Add Environment
Admin, Staging, Tenant B) and a Website URL, then set up its login the same way: Sign-in required plus one of the three methods.Point tests at the right environment
Re-authenticating an Expired Session (Method 3)
When a recorded SSO session expires, TestSprite tells you, and runs execute signed out until you refresh it.
Common Login Failures & Troubleshooting
My login sends a one-time code and Test account credentials gets stuck
My login sends a one-time code and Test account credentials gets stuck
I can't switch an existing project to OTP, or turn OTP off
I can't switch an existing project to OTP, or turn OTP off
Runs started failing after working fine (SSO project)
Runs started failing after working fine (SSO project)
The live browser won't open, or says the URL is unreachable
The live browser won't open, or says the URL is unreachable
localhost and private addresses can’t be opened from TestSprite’s cloud browser. Use a public staging URL, or set up the MCP server to test locally.An OTP run waited a while before starting
An OTP run waited a while before starting