question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Feature] Allow reconnecting to page in a separate processes

See original GitHub issue

Use Case: I need to connect to an existing page created in another process to create an end-to-end test.

The way I do this right now is by using launchServer in the first process and sending the wsEndpoint and page._delegate._targetId to the second process. Then I create a WebSocket manually in the second process that uses Target.attachToTarget to connect to the page.

Feature Request:

  1. Expose page.targetId()
  2. Allow passing targetId to browser.newBrowserCDPSession(targetId?: string);

Proposed Usage:

Process A.

const server = await playwright.chromium.launchServer();

const browser = await playwright.chromium.connect({
  wsEndpoint: server.wsEndpoint(),
});

const context = await browser.newContext();
const page = await context.newPage();

sendToProcessB({ 
  targetId: page.targetId(),
  wsEndpoint,
})

Process B.

const { targetId, wsEndpoint } = receiveFromProcessA();

const browser = await playwright.chromium.connect({ wsEndpoint });

const session = await browser.newBrowserCDPSession(targetId);

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pavelfeldmancommented, May 26, 2020

@kababoom I think you are talking about https://github.com/microsoft/playwright/issues/1745. I’m closing the session reconnect aspect for now.

0reactions
kababoomcommented, Apr 10, 2020

New to playwright, thank you for your time and effort creating this…

I’m also looking for a way to reconnect to a previously created session to cover my end-to-end testcases.

  • StartServer.js
  • Openpage.js page.goto-> evaluate element -> fill username/password -> take screenshot
  • Login.js click button -> check for element -> take screenshot.js etc…

So Login.js should continue with previously created Openpage.js session.

This would be the only way to integrate playwrite inside our existing framework and I’m not able to get this to work (yet).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reconnecting to Shiny apps - R Shiny - RStudio
To enable new-session reconnections, put session$allowReconnect(TRUE) somewhere in the server function. For example:.
Read more >
Remote Desktop client disconnects and can't reconnect to the ...
Troubleshooting an issue in which remote desktop client disconnects and can't reconnect to the same session.
Read more >
How to reconnect to a disconnected ssh session - Server Fault
When you first log in, run screen. You get another shell, run commands in that. If you're disconnected, the screen process keeps the...
Read more >
How to reconnect to websocket after close connection [duplicate]
The reason I want to do this is to allow users to stop sending data to the web temporary, and resending again after...
Read more >
Thread text among frames in Adobe InDesign
Connected frames can be on the same page or spread, or on another page in the document. The process of connecting text among...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found