Feature proposal: Ability to pass browserUrl to puppeteer.connect
See original GitHub issueDescription
Add support for new browserUrl
property in options
object passed to puppeteer.connect(options)
. It would accept url in form of http://{host}:{port}
which should point to the existing Chromium instance. For example:
puppeteer.connect({
browserUrl: http://localhost:9222
})
If this option is passed to puppeteer.connect
, then browserWSEndpoint
is retrieved from http://{host}:{port}/json/version
and passed new Connection()
. The rest of the flow remains unchanged.
If you’re OK with the proposal I could write up the code and the tests
Background
Currently to attach Puppeteer to an existing Chrome instance, one must provide url of browser websocket endpoint. For example:
puppeteer.connect({
browserWSEndpoint: ws://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8
})
However, as many issues raised here show (#2790, #1645, #940) browserWSEndpoint
is often not known to the code calling puppeteer.connect
, for example because Chrome was lunched in a docker container.
In such a case, a common and repeating scenario is to:
- make HTTP request to
http://{host}:{port}/json/version
- parse the response JSON
- get
browserWSEndpoint
from and use it inpuppeteer.connect
The steps above could be done by puppeteer resulting in less code in the user-land.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:5 (2 by maintainers)
Top GitHub Comments
@andrejska my PR #3558 is ready and awaiting review
How does one do this for Firefox? (After say using web-ext run to launch Firefox with an extension)