How to Fix Playwright Test Timeout Errors (“Test timeout of 30000ms exceeded”)
A Playwright test fails with Test timeout of 30000ms exceeded. when one test does not finish within the default 30-second limit. The Call log in the error shows what the test was waiting for at the moment it timed out, so start there. If the element you are waiting for is specified incorrectly, fix the locator. If the operation really takes that long, extend the time limit for that test only. This error can appear in E2E tests that check form submission or screen transitions after login, while the test is waiting for a button or heading to appear.
I reproduced this error in my test environment and confirmed how to read the output and that the error went away after the fix.
The test environment was Ubuntu 24.04, Node.js 22.23.4, and @playwright/test 1.63.0. I wrote the tests in TypeScript and ran them only in headless Chromium. I did not try Firefox or WebKit, Playwright in other languages such as Python, or connecting to a real server with page.goto(). The test page was built inline with page.setContent().
- 1. The test that caused the error and its output
- 2. How to read the error
- 3. Fixing the locator makes the error go away
- 4. Waiting for an operation that really takes 35 seconds
- 5. The 5-second limit of expect() is separate
- 6. Stop an operation earlier instead of waiting 30 seconds
- 7. When the timeout happens inside beforeEach
The test that caused the error and its output
For the test, I used a page that imitates a contact form. When the Send button is clicked, the status text changes to "Sending…", and after a specified delay it changes to "Sent" and a "Back to list" button appears. I made the delay a parameter.
// tests/page.ts
export const formPage = (delayMs: number) => `
<h1>お問い合わせ</h1>
<button id="send">送信</button>
<p id="status"></p>
<script>
document.querySelector('#send').addEventListener('click', () => {
document.querySelector('#status').textContent = '送信中…';
setTimeout(() => {
document.querySelector('#status').textContent = '送信しました';
const back = document.createElement('button');
back.textContent = '一覧へ戻る';
document.body.append(back);
}, ${delayMs});
});
</script>
`;
I wrote a test that clicks the "Back to list" button on a page where sending finishes in 0.5 seconds. However, I deliberately mistyped the button name by one particle, writing 一覧に戻る instead of 一覧へ戻る.
// tests/typo.spec.ts
import { test, expect } from '@playwright/test';
import { formPage } from './page';
test('送信して一覧へ戻る', async ({ page }) => {
await page.setContent(formPage(500));
await page.getByRole('button', { name: '送信' }).click();
await page.getByRole('button', { name: '一覧に戻る' }).click();
await expect(page.getByRole('heading')).toHaveText('お問い合わせ');
});
Running npx playwright test tests/typo.spec.ts failed after 30 seconds with the following output (exit code 1). Only the working directory path has been replaced with /path/to/app; everything else is unchanged.
Running 1 test using 1 worker
✘ 1 tests/typo.spec.ts:4:1 › 送信して一覧へ戻る (30.0s)
1) tests/typo.spec.ts:4:1 › 送信して一覧へ戻る ────────────────────────────────────────────────────────────
Test timeout of 30000ms exceeded.
Error: locator.click: Test timeout of 30000ms exceeded.
Call log:
- waiting for getByRole('button', { name: '一覧に戻る' })
5 | await page.setContent(formPage(500));
6 | await page.getByRole('button', { name: '送信' }).click();
> 7 | await page.getByRole('button', { name: '一覧に戻る' }).click();
| ^
8 | await expect(page.getByRole('heading')).toHaveText('お問い合わせ');
9 | });
10 |
at /path/to/app/tests/typo.spec.ts:7:53
Error Context: test-results/typo-送信して一覧へ戻る/error-context.md
1 failed
tests/typo.spec.ts:4:1 › 送信して一覧へ戻る ─────────────────────────────────────────────────────────────
How to read the error
From the top, the output tells you the following.
The first line, Test timeout of 30000ms exceeded., means the whole test went past its 30,000 ms (30-second) limit. According to the official documentation on timeouts, the default per-test limit is 30 seconds.
The next line, Error: locator.click: ..., shows the operation that was running when the timeout hit. Here it was click().
The Call log line waiting for getByRole('button', { name: '一覧に戻る' }) shows what that operation was waiting for. No button matched this locator, so the click could not proceed and kept waiting. The page only has 一覧へ戻る, so it would never be found no matter how long the test waited.
The line marked with > (line 7) and the ^ below it show where the test code was stopped.
Note that click() itself has no time limit of its own. In the official advanced low-level timeouts section, the per-action limit (Action timeout) defaults to "no timeout." So a click() with a wrong locator keeps waiting until the test's 30 seconds run out, and then produces this error.
Fixing the locator makes the error go away
I changed the button name to match the 一覧へ戻る label on the page. I saved the fixed test as tests/fixed.spec.ts under the name ボタンの名前を直す (Fix the button name) and ran it.
await page.getByRole('button', { name: '一覧へ戻る' }).click();
The test passed in 961 ms, and the error no longer appeared.
✓ 1 tests/fixed.spec.ts:4:1 › ボタンの名前を直す (961ms)
1 passed (1.7s)
Waiting for an operation that really takes 35 seconds
Even when the element is specified correctly, the operation itself may take longer than 30 seconds. I wrote a test that clicks the "Back to list" button on a page where sending takes 35 seconds (formPage(35_000)).
test('送信に35秒かかる', async ({ page }) => {
await page.setContent(formPage(35_000));
await page.getByRole('button', { name: '送信' }).click();
await page.getByRole('button', { name: '一覧へ戻る' }).click();
});
This test also failed with Test timeout of 30000ms exceeded. after 30 seconds. The Call log shows waiting for getByRole('button', { name: '一覧へ戻る' }). The locator name is correct, so in this case the time limit is simply too short.
To extend the limit for this test only, call test.setTimeout() inside the test. The value is in milliseconds.
test('送信に35秒かかる(setTimeout で60秒に延ばす)', async ({ page }) => {
test.setTimeout(60_000);
await page.setContent(formPage(35_000));
await page.getByRole('button', { name: '送信' }).click();
await page.getByRole('button', { name: '一覧へ戻る' }).click();
});
I tried different ways of extending the limit on the same 35-second page. The table below shows the results. Each one passed in a little over 35 seconds.
| How to extend | Where to write it | Result |
|---|---|---|
test.setTimeout(60_000) |
Inside the test | Passed (35.2s) |
test.slow() |
Inside the test | Passed (35.1s) |
timeout: 60_000 |
playwright.config.ts |
Passed (35.2s) |
--timeout=60000 |
Option for npx playwright test |
Passed (35.2s) |
test.slow() triples the time limit for that test compared with the default. The timeout setting in the config file and the --timeout command-line option change the limit for all tests. If only some tests are slow, use test.setTimeout() or test.slow() inside those tests, and the other tests keep the 30-second limit.
The 5-second limit of expect() is separate
I also tried waiting for the "Sent" text to appear with expect(), instead of clicking the button. The test limit was already extended to 60 seconds with test.setTimeout(60_000).
await expect(page.locator('#status')).toHaveText('送信しました');
This failed after 5 seconds. The error message is also different from the test timeout.
Error: expect(locator).toHaveText(expected) failed
Locator: locator('#status')
Expected: "送信しました"
Received: "送信中…"
Timeout: 5000ms
Assertions such as toHaveText(), which keep checking until the condition is met, have their own time limit separate from the test timeout, and the default is 5 seconds. The official expect timeout section also states that this limit is "unrelated to the test timeout." Passing { timeout: 40_000 } to this expect() made it pass in 35.2 seconds.
await expect(page.locator('#status')).toHaveText('送信しました', { timeout: 40_000 });
I tried four ways of writing the wait on the page where sending takes 35 seconds. The timeline below shows where each one stopped: the default settings, test.setTimeout(60_000), waiting with expect(), and passing timeout to expect() as well.

If the error is Test timeout of 30000ms exceeded., extend the whole-test limit. If it shows Timeout: 5000ms, extend the limit of the expect() call.
Stop an operation earlier instead of waiting 30 seconds
When you wait for an element that never appears, as with a misspelled name, waiting the full 30 seconds each time feels long. You can add actionTimeout under use in the config file to set a time limit on each operation such as click().
// playwright.action.config.ts
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: './tests',
reporter: 'list',
use: { browserName: 'chromium', actionTimeout: 10_000 },
});
I ran the test with the misspelled button name using this config (-c playwright.action.config.ts). It failed after 10.1 seconds, and the error changed to TimeoutError.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
- waiting for getByRole('button', { name: '一覧に戻る' })
The Call log still shows the locator being waited on. However, the official documentation says that the advanced low-level timeouts, including this actionTimeout, "usually do not need to be changed." It also notes that if you are looking for this setting because tests are flaky, the cause is usually somewhere else. Fix the locator being waited on first.
When the timeout happens inside beforeEach
I also tried the case where the test waits inside test.beforeEach(), which runs before every test. The test waits for a 35-second send to finish as setup in beforeEach.
test.beforeEach(async ({ page }) => {
await page.setContent(formPage(35_000));
await page.getByRole('button', { name: '送信' }).click();
await page.getByRole('button', { name: '一覧へ戻る' }).waitFor();
});
test('準備が終わったあとの確認', async ({ page }) => {
await expect(page.getByRole('heading')).toHaveText('お問い合わせ');
});
In this case, the first line of the error had while running "beforeEach" hook appended (the path is replaced with /path/to/app).
Test timeout of 30000ms exceeded while running "beforeEach" hook.
2 | import { formPage } from './page';
3 |
> 4 | test.beforeEach(async ({ page }) => {
| ^
5 | await page.setContent(formPage(35_000));
6 | await page.getByRole('button', { name: '送信' }).click();
7 | await page.getByRole('button', { name: '一覧へ戻る' }).waitFor();
at /path/to/app/tests/hook.spec.ts:4:6
Error: locator.waitFor: Test timeout of 30000ms exceeded.
Call log:
- waiting for getByRole('button', { name: '一覧へ戻る' }) to be visible
The test body only checks a heading, but it failed because beforeEach had already used up the 30 seconds. As the official documentation states, the time spent in beforeEach and in fixture setup counts toward the test's 30 seconds. If the test body does not explain the failure, check whether the first line includes while running.





