Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature proposal: Ability to pass browserUrl to puppeteer.connect #3537

Closed
lukaszfiszer opened this issue Nov 13, 2018 · 5 comments
Closed
Labels
chromium Issues with Puppeteer-Chromium feature

Comments

@lukaszfiszer
Copy link
Contributor

Description

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:

  1. make HTTP request to http://{host}:{port}/json/version
  2. parse the response JSON
  3. get browserWSEndpoint from and use it in puppeteer.connect

The steps above could be done by puppeteer resulting in less code in the user-land.

@aslushnikov
Copy link
Contributor

@lukaszfiszer fair. I'd be happy to review a PR.

@andrejska
Copy link

any update on this issue?

@lukaszfiszer
Copy link
Contributor Author

@andrejska my PR #3558 is ready and awaiting review

@aslushnikov aslushnikov added the chromium Issues with Puppeteer-Chromium label Dec 6, 2018
aslushnikov pushed a commit that referenced this issue Jan 14, 2019
The `browserURL` option allows to connect to a browser that exposed it's remote debugging protocol on a known port.

Fixes #3537
aslushnikov added a commit to aslushnikov/puppeteer that referenced this issue Jan 14, 2019
This patch:
- renames `browserUrl` into `browserURL`
- cleans up some code
- adds tests for error handling

References puppeteer#3537
aslushnikov added a commit that referenced this issue Jan 14, 2019
This patch:
- renames `browserUrl` into `browserURL`
- cleans up some code
- adds tests for error handling

References #3537
@neel2407
Copy link

Thanks for adding this feature, it is a game changer.

@sublimator
Copy link

How does one do this for Firefox? (After say using web-ext run to launch Firefox with an extension)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chromium Issues with Puppeteer-Chromium feature
Projects
None yet
Development

No branches or pull requests

6 participants
@sublimator @aslushnikov @lukaszfiszer @neel2407 @andrejska and others