Skip to main content
Running Stably-powered Playwright tests locally uses the exact same workflow you use with Playwright. Everything documented in Playwright’s Running Tests guide applies—Stably SDK is a drop-in replacement that adds AI-powered capabilities while maintaining 100% API compatibility.
Stably’s no-code AI tests run in the cloud only. Local execution is supported for the Playwright SDK workflow described here.

Prerequisites

  • Node.js 18+ installed on your machine
  • A test directory for your e2e tests

Setup

1

Remove existing Playwright (if installed)

If you already have Playwright installed:
cd your-e2e-tests-directory
npm remove playwright @playwright/test
2

Install Stably Playwright SDK

Navigate to your e2e tests directory:
cd your-e2e-tests-directory
npm install @stablyai/playwright-test@^0.1.2
3

Setup API Key

Get a Team API Key from your Stably Settings and set it as an environment variable:
export STABLY_API_KEY=your_api_key_here
You can also programmatically set the key using the setApiKey function:
import { setApiKey } from "@stablyai/playwright-test";

setApiKey("your_api_key_here");
4

Update Your Test Imports

Replace all imports from @playwright/test with @stablyai/playwright-test:
// Before
import { test, expect } from "@playwright/test";

// After
import { test, expect } from "@stablyai/playwright-test";

Run Tests

Use the same Playwright commands you’re already familiar with:
npx playwright test
The Stably SDK supports all standard Playwright commands and flags:
  • Run tests in headed mode: npx playwright test --headed
  • Run a specific test file: npx playwright test tests/example.spec.ts
  • Run tests in UI mode: npx playwright test --ui
  • Run a single project/browser: npx playwright test --project=chromium
  • Filter tests by name: npx playwright test --grep "login"
For complete command reference, see the Playwright CLI documentation.

Enable AI Auto-Heal (Optional)

To enable AI auto-heal capabilities, create a stably.config.ts file in the same folder as your playwright.config.ts:
Model support: Stably currently supports only claude-sonnet-4-5 for auto-heal functionality. This model has demonstrated the best accuracy and reliability for both locator and screenshot healing.
stably.config.ts
import { defineStablyConfig } from '@stablyai/playwright-test';

export default defineStablyConfig({
  use: {
    autoHeal: {
      enabled: true,
      model: 'claude-sonnet-4-5',
      
      // Locator-specific config
      locators: {
        enabled: true,
        timeout: 30000,
      },
      
      // Screenshot-specific config
      screenshots: {
        enabled: true,
      },
    },
  },
});

Next Steps

I