How to fix Playwright TimeoutError when an action exceeds timeout?

Playwright

TimeoutError usually means Playwright could not find an actionable element in time.

Use a more specific locator, wait for UI readiness, and set a realistic timeout.

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

test('click when ready', async ({ page }) => {
  await page.goto('https://example.com/login');

  const submit = page.getByRole('button', { name: 'Sign in' });
  await expect(submit).toBeVisible({ timeout: 10000 });
  await submit.click({ timeout: 10000 });
});

If this happens often, set defaults once:

test.use({ actionTimeout: 10000, navigationTimeout: 15000 });