[Question] Attaching playwright to an existing browser window?
See original GitHub issueHey,
First of all thank you for this wonderful library ❤️
I’m working on a feature for playwright recorder to let you more easily run playwright tests from the browser.
I want to attach playwright to a context that is already running (opened with ChromeDriver if that matters):
const browser = await playwright.chromium.connect({
wsEndpoint: cdpUrl,
});
const contexts = browser.contexts(); // empty
// how do I get the existing already open pages?
const context = await browser.newContext({viewport: null })
const pages = await context.pages(); // empty
I checked puppeteer and it was easy to get working like this:
const browser = await puppeteer.connect({
browserWSEndpoint: cdpUrl,
defaultViewport: null, // disable puppeteer resize
product: 'chrome',
});
const pages = await browser.pages();
const page = last(pages);
Is there an official method to obtain existing browser contexts?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:6
- Comments:44 (30 by maintainers)
Top Results From Across the Web
3 Ways of Attaching to Existing Browsers in Web Automation
We are introducing the browser attaching method for different automation libraries here, containing Selenium, Playwright and Clicknium.
Read more >Is there a way to connect to my existing browser session using ...
You can use puppeteer-core or playwright to control your existing browser installation, for example Chrome, and then use the existing user data ...
Read more >Playwright allows you to connect to existing browser instances ...
Playwright allows you to connect to existing browser instances, but it currently requires you to get the “debug URL” of the browser instance ......
Read more >How to start with Playwright Debugging | BrowserStack
A step-by-step tutorial to perform Playwright Debugging and help you choose a suitable option to deliver a high-quality web application.
Read more >Playwright: Launching Cross-Browser Automation to the Stars
This problem was not solved until the last weeks, when we added parallel Playwright tests execution support to Moon — a browser automation ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’ll tentatively close this as won’t fix. It is essential for Playwright to be able to run the browser in the controlled environment. There are a lot of good hints here on how this can be worked around, but it is unlikely that they get into the official Playwright API.
I’ll try to describe the use case:
The feature I’m asking for enables mixing and matching playwright with selenium or puppeteer more easily. I specifically need it to run the playwright playground (mentioned above) on tabs controlled inside ChromeDriver