-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Closed
Description
Hi,
I am trying to verify expected data is being sent to an api. I am able to access the response data, but not the request data. How do you grab the request payload data inside playwright? I am calling request.postDataJson() which is returning null.
I created an example to demo my issue, and I ran into the same thing for post request on google.com.
const { getEdgePath } = require("edge-paths");
(async () => {
const browser = await chromium.launch({headless: false, devtools: true, executablePath: getEdgePath() });
const page = await browser.newPage();
const [loadRes] = await Promise.all([
page.waitForRequest(req => req.url().startsWith("https://browser.events.data.msn.com/OneCollector")),
await page.goto("https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing&query=enterprise")
]);
console.log(loadRes.url());
console.log(loadRes.postDataJSON());
await browser.close();
})();
(async () => {
const browser = await chromium.launch({headless: false, devtools: true, executablePath: getEdgePath() });
const page = await browser.newPage();
const [loadRes] = await Promise.all([
page.waitForRequest(req => req.url().startsWith("https://play.google.com")),
await page.goto("https://google.com")
]);
console.log(loadRes.url());
console.log(loadRes.postDataJSON());
await browser.close();
})();
Metadata
Metadata
Assignees
Labels
No labels