connect
Connects to the Chrome debugger at the given wsOrHttpUrl (either web socket or HTTP), opening a BrowserSession.
if wsOrHttpUrl is a
ws://orwss://URL, this function directly connects to the browser target via the web socket. It should be something likews://localhost:9222/devtools/browser/b0b8a4fb-bb17-4359-9533-a8d9f3908bd8. If you're using services like Browserless's Docker image, you might have a simpler URL likews://localhost:3000orws://localhost:3000?token=6R0W53R135510.if wsOrHttpUrl is an
http://orhttps://URL, this function finds the web socket debugger URL via the HTTP API, and then uses it to open the web socket to the Chrome debugger.
If you have access to the web socket URL, it is preferable to use that one to avoid the extra hop.
The returned BrowserSession only provides a limited subset of the possible operations, because it is attached to the default browser target, not a page target. To create a new page (tab), use newPage and then interact with it through the returned PageSession. Refer to the documentation of BrowserSession for more info.
The caller of this method is responsible for closing the web socket after use by calling BrowserSession.close, or using the auto-close capabilities via use. Because all child sessions of the returned BrowserSession use the same underlying web socket connection, calling ChildSession.close or use on a derived session doesn't close the connection (to avoid undesirable interactions between child sessions).
Parameters
the HTTP or web socket URL of the Chrome debugger.
a custom CoroutineContext for the coroutines used in the Chrome session to process events
Adds extra configuration to the default HttpClient used to connect to the debugger's web socket. If you need to reuse an existing HttpClient entirely, use the HttpClient.connectChromeDebugger extension instead.