Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Edge does not report request payload #4037

Closed
ethanwc opened this issue Oct 1, 2020 · 3 comments
Closed

[BUG] Edge does not report request payload #4037

ethanwc opened this issue Oct 1, 2020 · 3 comments

Comments

@ethanwc
Copy link

ethanwc commented Oct 1, 2020

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();
})();

@arjunattam
Copy link
Contributor

arjunattam commented Oct 1, 2020

Thanks @ethanwc. I'm able to repro with the following script. It seems that none of the requests to browser.events... return a post body, but if I see the same request in browser dev tools, I can see "request payload".

This is on Edge version 87.0.654.0 (Official build) Dev (64-bit). This url doesn't work in plain Chromium and I wonder if the browser is behaving differently for this particular url.

const { chromium } = require('playwright');
const { getEdgePath } = require("edge-paths");

(async () => {
  const browser = await chromium.launch({
    headless: false, devtools: true, executablePath: getEdgePath()
  });

  const page = await browser.newPage();
 
  page.on('request', request => {
    if (request.url().includes('browser.events'))
      console.log(request.postData())
  });

  await page.goto("https://ntp.msn.com/edge/ntp?locale=en&dsp=1&sp=Bing&query=enterprise");
  await page.waitForTimeout(50000);
  await browser.close();
})();

Screen Shot 2020-10-01 at 2 36 54 PM

@arjunattam arjunattam changed the title [Question] How can I access the Request Payload in playwright? [BUG] Edge does not report request payload Oct 1, 2020
@dgozman
Copy link
Contributor

dgozman commented Nov 23, 2020

The snippet from @arjunattam works for me with Edge 87.0.664.41 on MacOS 10.15. Did the issue fix itself on your end?

@pavelfeldman
Copy link
Member

Closing as per above, please file it and link to this issue if it repros on 1.6!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants