Skip to content

[BUG] WebSocketRoute not working properly #31

@josegrobles

Description

@josegrobles

System info

  • Playwright Version: 1.49.1
  • Operating System: All
  • Browser: Chrome

Source code

const { chromium } = require('patchright');

(async () => {
  const browser = await chromium.launch({
    headless: false,
    viewport: null,
    channel: 'chrome',
  });
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.routeWebSocket(() => true, ws => {
    const server = ws.connectToServer();
    ws.onMessage(message => {
      console.log('sent',message);
      server.send(message);
    });
    server.onMessage(message => {
      console.log('received',message);
      ws.send(message);
    });
  });

  await page.goto('https://www.olybet.ee/sports/live');
})();
  • I provided exact source code that allows reproducing the issue locally.

Steps

  • Run the provided Script

Expected

Logs all the messages from WebSocket connections on the current page.

Actual

Nothing is logged. If you try with the regular Playwright it works properly.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or requestgood first issueGood for newcomerswontfixThis will not be worked on

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions