BrauzerLab
← Back to missions 25 / 50

Wait for an API Response

Medium ~180 sec

When you click a button, a background request starts. If you assert the UI before the response arrives, the test becomes unreliable. The waitForResponse call solves this problem: it waits for the matching HTTP response.

Usage: call await page.waitForResponse('/api/submit') first, then click the button. A URL glob ('**/api/submit') also works.

page is available. Wait for the /api/submit response before clicking the Send button.

TASK

Wait for the API response.

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

test('Wait for an API Response', async ({ page }) => {
  await page.goto('https://lab.local/mission/wait-for-response');
  // ↓ Your code goes below ↓
});
Editor
https://lab.local/mission/wait-for-response
Loading...
Results will appear here — press Run or Check.