Authentication is a critical part of any application. If you’re building tests that cover the parts of your app users actually care about, chances are you’ll need to log in. Whether it’s a simple email/password form or a more complex Google SSO flow, being able to authenticate reliably is key to building meaningful and trustworthy tests. In this guide, we’ll walk you through how to set up and use authentication in your tests using Stably.

Setting Up Test Accounts

Before testing authentication, you’ll need to set up some test credentials.

Email-Based Test Accounts

You can store these as environment variables within your project:
  1. Go to app.stably.ai
  2. From the sidebar, click Test Data
  3. Navigate to the Variables tab
  4. Fill out the name-value pair (you can use JSON):
    Name: test_account  
    Value: { "email": "test@email.com", "password": "testpassword" }
    
    Make sure the JSON is properly formatted!
  5. Click Save
You can now access this test account in your test logic using:
VARS.test_account.email
VARS.test_account.password

SSO Test Accounts (e.g. Google)

Set up your SSO test accounts under the same Test Data > Test Accounts section.
We’ve already documented how to do this. You can follow the detailed guide here: Google OAuth Setup

Logging Into Your App in a Test

Once your test accounts are set up, here’s how to use them during test recording.

Email-Based Logins

A quicker alternative to the steps below is to use Stably’s AI agent to create the login actions. In the Add Step menu, simply select the AI Act option and instruct it to login using your test account variable (ie. “Login using the test_account credentials”)
  1. Start recording your test as usual.
  2. When the login screen appears:
    • Right-click the email field → choose Fill
    • In the modal, set the input type to Dynamic
    • Enter: `VARS.test_account.email`
  3. Repeat the same steps for the password field using `VARS.test_account.password`
  4. Click Login and continue recording the rest of your test.

Google SSO Logins

Ensure your Google test account is already set up
  1. From the Add Step or Add Operation menu, choose Login to Google
  2. In the modal, select the test account you want to use from the dropdown
  3. Click Select to confirm
  4. Begin recording your test
  5. When prompted in the login form, click Sign in with Google and the login flow should proceed automatically, since the Google account is already logged in thanks to the previous “Login with Google” action
  6. (Optional) Visit https://accounts.google.com in the recorder to confirm that the login worked

Migrating from the Old “Auth Steps”

If you’ve used Stably before, you might be familiar with the older auth steps — AI-powered steps that bundled all the logic into a single step. These legacy auth steps have now been deprecated. They’ve been replaced with more flexible, modular actions like “Login to Google”, which you can combine with regular Playwright actions (click, fill, etc.) and Stably environment variables to create reliable, customizable login flows.

Final Notes

Authentication can be complex — especially when anti-bot measures are in play. With Stably’s new modular login features and environment variable support, we aim to make testing auth flows as seamless and flexible as possible.
Need help with authentication? Don’t hesitate to reach out to our team at help@stably.ai