Skip to content

End-to-End Test Automation

Your signup flow works perfectly when you test it manually. Then QA reports that users on Safari with autofill enabled cannot submit the form because the password validation fires before autofill completes. Your unit tests and integration tests never caught this because they do not run in a real browser. E2E tests exist to simulate what actual users do — and AI makes writing them dramatically faster.

  • Workflows for generating Playwright tests from user stories and acceptance criteria
  • Page Object Model generation that keeps E2E tests maintainable
  • Visual regression testing integration for catching UI drift
  • Strategies for handling authentication, dynamic content, and flaky tests
  • Cross-browser and mobile viewport configuration patterns

The fastest path to E2E tests: translate your user stories directly into Playwright scripts.

Generate Playwright E2E tests for this user story:
"As a registered user, I can purchase a subscription:
1. I log in with email and password
2. I navigate to the pricing page
3. I click 'Subscribe' on the Pro plan
4. I enter my credit card details
5. I see a success confirmation with my new plan name
6. My dashboard shows 'Pro' as my current plan"
Requirements:
- Use Page Object Model for each page (LoginPage, PricingPage, CheckoutPage, DashboardPage)
- Handle the Stripe Elements iframe for card input
- Use test credit card 4242424242424242
- Assert at each step, not just the final state
- Include proper waits (no arbitrary timeouts)
- Tag as @purchase for selective test running
Save page objects to /tests/e2e/pages/
Save the test to /tests/e2e/flows/purchase-subscription.spec.ts

AI excels at generating Page Objects because the pattern is highly structured.

Catch unexpected UI changes by comparing screenshots across test runs.

Create an authentication helper for our Playwright tests that:
1. Has a storageState approach:
- A global setup that logs in once and saves the auth state
- Tests reuse the saved state (no login per test = faster suite)
- Different states for: regularUser, adminUser, unauthenticatedUser
2. Save to /tests/e2e/auth/global-setup.ts and /tests/e2e/auth/states/
3. Configure playwright.config.ts to use global setup
and make auth states available via test fixtures
4. Show usage in a test:
test('admin can access user management', async ({ adminPage }) => {
// adminPage is already authenticated as admin
})

“E2E tests take 20 minutes and developers skip them.” Parallelize across multiple workers (Playwright supports this natively). Run only critical-path tests on every PR, full suite nightly. Use the --shard option in CI to distribute across multiple runners.

“Tests break every time the UI changes.” You are using fragile selectors. Switch to data-testid attributes that are stable across design changes. Ask the AI to “rewrite all selectors to use data-testid instead of CSS classes or text content.”

“Visual regression tests fail due to font rendering differences.” Different OS font rendering causes pixel differences. Use Docker containers for consistent rendering in CI. Set a higher comparison threshold (0.5%) or mask text-heavy areas.

“The AI cannot interact with third-party iframes (Stripe, reCAPTCHA).” Use test modes for third-party services. Stripe provides test mode with predictable behavior. For reCAPTCHA, use the site key that always passes in test environments.