chrome-devtools-kotlin / org.hildan.chrome.devtools.targets / ChromeBrowserSession

ChromeBrowserSession

class ChromeBrowserSession : AbstractTargetSession, BrowserTarget

A browser session, usually created when initially connecting to the browser's debugger.

Functions

close

Closes this session and the underlying web socket connection. This effectively closes every session based on the same web socket connection.

suspend fun close(): Unit

Extension Functions

attachToNewPage

Creates and attaches to a new page (tab) initially navigated to the given url. The underlying web socket connection of this ChromeBrowserSession is reused for the new ChromePageSession.

suspend fun ChromeBrowserSession.attachToNewPage(url: String = "about:blank", incognito: Boolean = true, width: Int = 1024, height: Int = 768, background: Boolean = false): ChromePageSession

attachToNewPageAndAwaitPageLoad

Creates and attaches to a new page (tab) initially navigated to the given url. Suspends until the frameStoppedLoading event is fired. The underlying web socket connection of this ChromeBrowserSession is reused for the new ChromePageSession.

suspend fun ChromeBrowserSession.attachToNewPageAndAwaitPageLoad(url: String = "about:blank", incognito: Boolean = true, width: Int = 1024, height: Int = 768, background: Boolean = false): ChromePageSession

attachToPage

Creates a new ChromePageSession attached to the page target with the given targetId. The new session shares the same underlying web socket connection as this ChromeBrowserSession.

suspend fun ChromeBrowserSession.attachToPage(targetId: TargetID): ChromePageSession

use

Performs the given operation in this session and closes the web socket connection.

suspend fun <T> ChromeBrowserSession.use(block: (ChromeBrowserSession) -> T): T

watchTargetsIn

Watches the available targets in this browser.

suspend fun ChromeBrowserSession.watchTargetsIn(coroutineScope: CoroutineScope): StateFlow<Map<TargetID, TargetInfo>>