1

Is there a way to intercept and mock WebSockets requests/responses with puppeteer?

  page.on('request', request => {
    console.log('Intercepting Request ', request, { depth: null });
    request.continue();
  });

  page.on('response', response => {
    console.log('Intercepting Response ', response, { depth: null });
    response.abort();
  });

does not show the requests/responses made through WebSocket. This How to use puppeteer to dump WebSocket data is answering the question somewhat, but not by using puppeteer but by using ws.

four-eyes
  • 10,740
  • 29
  • 111
  • 220
  • Possible duplicate of [How to use puppeteer to dump WebSocket data](https://stackoverflow.com/questions/48375700/how-to-use-puppeteer-to-dump-websocket-data) – Tristan De Oliveira Mar 05 '19 at 10:40

1 Answers1

-1

Did you set the request interception?

   await page.setRequestInterception(true)
   page.on('request', interceptedRequest => {
     interceptedRequest.continue()
   })
Pjotr Raskolnikov
  • 1,558
  • 2
  • 15
  • 27