Prompt

How do I set up browser-based end-to-end testing for my web app?

Technology / Testing & QA2 observationsLast seen Nov 3, 2026

Latest observation

Nov 3, 2026OpenAI APIWeb search: off

To set up browser-based end-to-end (E2E) testing for a web app, the most common path is:

  1. pick a browser automation tool
  2. install it in your project
  3. write tests that open your app in a real browser
  4. run them locally and in CI

A practical modern choice is Playwright. It’s fast, reliable, and supports Chromium, Firefox, and WebKit.


1) Choose a tool

Common options:

  • Playwright — recommended for most new projects
  • Cypress — also popular, great developer experience
  • Selenium/WebDriver — older standard, useful for compatibility or enterprise setups

If you’re starting fresh, use Playwright.


2) Install Playwright

If you use Node.js

npm init playwright@latest

This will:

  • install Playwright
  • set up example tests
  • configure browsers

Or, if you already have a project:

npm install -D @playwright/test
npx playwright install

3) Make your app testable

E2E tests are much easier if your UI has stable selectors.

Good practices

  • Use data-testid attributes
  • Prefer accessible roles and labels
  • Avoid brittle CSS selectors or text that changes often

Example:

<button data-testid="login-button">Log in</button>

Then in tests:

await page.getByTestId('login-button').click();

Even better when possible:

await page.getByRole('button', { name: 'Log in' }).click();

4) Write a simple test

Example Playwright test:

import { test, expect } from '@playwright/test';

test('homepage has title and can navigate', async ({ page }) => {
  await page.goto('http://localhost:3000');

  await expect(page).toHaveTitle(/My App/);

  await page.getByRole('link', { name: 'Sign in' }).click();
  await expect(page).toHaveURL(/\/login/);
});

5) Run your app and tests

Usually you’ll need:

  • your web app running locally
  • the test runner executing against it

For example:

npm run dev
npx playwright test

If your app starts on a different port, update the test URL.


6) Configure base URL

In playwright.config.ts:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  use: {
    baseURL: 'http://localhost:3000',
  },
});

Then tests can do:

await page.goto('/');

7) Add setup for auth and test data

For real-world E2E testing, you’ll want:

  • seeded test data
  • a dedicated test database
  • a test login flow or storage state reuse

Example: reuse signed-in state

You can log in once and save session state:

import { test as setup, expect } from '@playwright/test';

setup('authenticate', async ({ page }) => {
  await page.goto('/login');
  await page.getByLabel('Email').fill('test@example.com');
  await page.getByLabel('Password').fill('password123');
  await page.getByRole('button', { name: 'Sign in' }).click();

  await expect(page).toHaveURL('/');
  await page.context().storageState({ path: 'storageState.json' });
});

Then use it in tests:

use: {
  storageState: 'storageState.json',
}

8) Run tests in CI

In GitHub Actions, for example:

name: e2e
on: [push, pull_request]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npx playwright install --with-deps
      - run: npm run test:e2e

If your app must be started first, use a tool like:

  • start-server-and-test
  • a custom CI step that runs the app in the background

9) Keep tests stable

E2E tests can be flaky if they depend on timing or unstable state. To reduce flakiness:

  • wait for UI state instead of hardcoded sleeps
  • use Playwright’s built-in assertions
  • isolate test data
  • make tests independent
  • avoid relying on animation timing
  • retry only as a last resort

Bad:

await page.waitForTimeout(5000);

Better:

await expect(page.getByText('Dashboard loaded')).toBeVisible();

10) Suggested structure

A typical setup:

tests/
  e2e/
    login.spec.ts
    checkout.spec.ts
playwright.config.ts

Recommended baseline setup

If you want the simplest robust setup:

  • use Playwright
  • add data-testid or accessible labels
  • run your app on localhost
  • configure baseURL
  • use a test database or mocked backend where appropriate
  • run in CI on every pull request

If you want, I can also give you:

  1. a Playwright setup for React / Next.js / Vue / Angular
  2. a Cypress setup
  3. a full GitHub Actions CI example
  4. a sample login flow test

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (2 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.