'Unable to capture response.json() in playwright
I am trying to capture json response using playwright. I keep on getting Promise pending. However under headless:false mode i can see the data is being received and populated on the browser. I have just started playing with Playwright and also not very familiar with "Promise".
What i have tried is as below:
(async () => {
let browser = await firefox.launch({headless: true, userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Firefox/68.0'});
let page = await browser.newPage();
page.waitForResponse(async(response) => {
if (response.url().includes('/abcd') && response.status() == 200) {
let resp = await response.json();
console.log(resp);
}
});
await page.goto('https://myurl.com', {waitUntil: 'networkidle', timeout: 30000});
await page.waitForTimeout(20000);
await browser.close();
})
What am i doing wrong? I have tried increasing timeout. Doesnot help.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
