[Feature] Better logs in trace viewer for waitForRequest/waitForResponse
Is it possible to get the request and response from a waitForRequest and waitForResponse in the trace viewer? Because right now, it really lacks any information to help debug.
It doesn't even have information on what URL it fulfilled
@A-ZC-Lau what language are you using? Is it Java?
@aslushnikov javascript
@A-ZC-Lau
I tried the following simple test:
// a.spec.ts
import { test, expect } from '@playwright/test';
test('should work', async ({ page }) => {
await Promise.all([
page.goto('https://example.com'),
page.waitForRequest('https://example.com'),
]);
});
And I ended up with the following trace that has a URL:
Could you please try this? Does it work for you?
@aslushnikov I'm running my tests using the function way
import {test} from "@playwright/test";
const api = "https://www.airbnb.com.au/api/v2/user_markets";
test("waitForRequest", async function ({page}) {
const r = new RegExp(api);
await page.route(r, route => {
route.fulfill({
body : "",
status : 200,
});
});
const [req] = await Promise.all([
page.waitForRequest(route => {
const url = route.url().match(r);
const method = route.method() === "GET";
return !!url && method;
}),
page.goto("https://www.airbnb.com"),
]);
});
But even with the string parameter, it doesn't show what the request/response (for waitForResponse) were.
Would it be possible to have these details added in future versions?
I landed here from Google trying to find #15690
Commenting in case future travelers are in the same boat