webSocket

Opens a web socket connection to interact with the browser.

This method attaches to the default browser target, which creates a root session without session ID. The returned BrowserSession thus only provides a limited subset of the possible operations (only the ones applicable to the browser itself).

To attach to a specific target (such as a web page), call BrowserSession.attachToPage, BrowserSession.attachToNewPage, or similar functions. This creates a nested session with a type corresponding to the target type, which provides access to another set of domains. Such nested sessions use the same underlying web socket connection as the initial browser session returned here.

Note that the caller of this method is responsible for closing the web socket after use by calling BrowserSession.close, or indirectly by calling use() on the browser session. Calling close() or use() on a derived PageSession doesn't close the underlying web socket connection, to avoid undesirable interactions between nested sessions.