BrauzerLab
← Back to missions 21 / 50

Custom Timeout in `expect`

Easy ~120 sec

Sometimes a UI element loads later than expected — due to a network response, animation, or server delay. In such cases Playwright’s default timeout may not be enough.

In Playwright you can set a custom timeout by passing a numeric value via expect(locator, { timeout: ms }). This makes the assertion wait up to the specified number of milliseconds.

page is already available. In the browser on the right there is a #status element. Assert its content with { timeout: 8000 } (or any other ms value).

Passing the timeout value inside the expect call is sufficient — it applies only to that single assertion.

TASK

Wait up to 10 seconds.

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

test('Custom Timeout in `expect`', async ({ page }) => {
  await page.goto('https://lab.local/mission/custom-timeout');
  // ↓ Your code goes below ↓
});
Editor
https://lab.local/mission/custom-timeout
Loading...
Results will appear here — press Run or Check.