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.

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

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 connection.

suspend fun <T, S : AbstractTargetSession> S.use(block: (S) -> T): T

watchTargetsIn

Watches the available targets in this browser.

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