-
public final class TargetExtensionsKt
-
-
Method Summary
Modifier and Type Method Description final ChromePageSessionattachToPage(ChromeBrowserSession $self, String targetId)Creates a new ChromePageSession attached to the page target with the given targetId. final ChromePageSessionattachToNewPage(ChromeBrowserSession $self, String url, Boolean incognito, Integer width, Integer height, Boolean background)Creates and attaches to a new page (tab) initially navigated to the given url. final ChromePageSessionattachToNewPageAndAwaitPageLoad(ChromeBrowserSession $self, String url, Boolean incognito, Integer width, Integer height, Boolean background)Creates and attaches to a new page (tab) initially navigated to the given url. final UnitnavigateAndAwaitPageLoad(ChromePageSession $self, String url)Navigates the current page according to the provided url, and suspends until the corresponding frameStoppedLoadingevent is received.final UnitnavigateAndAwaitPageLoad(ChromePageSession $self, NavigateRequest navigateRequest)Navigates the current page according to the provided navigateRequest, and suspends until the corresponding frameStoppedLoadingevent is received.final <T extends Any> Tuse(ChromeBrowserSession $self, Function1<ChromeBrowserSession, T> block)Performs the given operation in this session and closes the web socket connection. final <T extends Any> Tuse(ChromePageSession $self, Function1<ChromePageSession, T> block)Performs the given operation in this session and closes the target. final TargetInfogetTargetInfo(ChromePageSession $self)Retrieves information about this session's page target. final StateFlow<Map<String, TargetInfo>>watchTargetsIn(ChromeBrowserSession $self, CoroutineScope coroutineScope)Watches the available targets in this browser. -
-
Method Detail
-
attachToPage
final ChromePageSession attachToPage(ChromeBrowserSession $self, String targetId)
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.
If the given ID corresponds to a target that is not a page, an exception is thrown.
-
attachToNewPage
final ChromePageSession attachToNewPage(ChromeBrowserSession $self, String url, Boolean incognito, Integer width, Integer height, Boolean background)
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.
If incognito is true, the new target is created in a separate browser context (think of it as incognito window).
You can use width and height to specify the viewport dimensions in DIP (Chrome Headless only).
If background is true, the new tab will be created in the background (Chrome only).
-
attachToNewPageAndAwaitPageLoad
final ChromePageSession attachToNewPageAndAwaitPageLoad(ChromeBrowserSession $self, String url, Boolean incognito, Integer width, Integer height, Boolean background)
Creates and attaches to a new page (tab) initially navigated to the given url. Suspends until the
frameStoppedLoadingevent is fired. The underlying web socket connection of this ChromeBrowserSession is reused for the new ChromePageSession.If incognito is true, the new target is created in a separate browser context (think of it as incognito window).
You can use width and height to specify the viewport dimensions in DIP (Chrome Headless only).
If background is true, the new tab will be created in the background (Chrome only).
-
navigateAndAwaitPageLoad
final Unit navigateAndAwaitPageLoad(ChromePageSession $self, String url)
Navigates the current page according to the provided url, and suspends until the corresponding
frameStoppedLoadingevent is received.
-
navigateAndAwaitPageLoad
final Unit navigateAndAwaitPageLoad(ChromePageSession $self, NavigateRequest navigateRequest)
Navigates the current page according to the provided navigateRequest, and suspends until the corresponding
frameStoppedLoadingevent is received.
-
use
final <T extends Any> T use(ChromeBrowserSession $self, Function1<ChromeBrowserSession, T> block)
Performs the given operation in this session and closes the web socket connection.
Note: This effectively closes every session based on the same web socket connection.
-
use
final <T extends Any> T use(ChromePageSession $self, Function1<ChromePageSession, T> block)
Performs the given operation in this session and closes the target.
This preserves the underlying web socket connection (of the parent browser session), because it could be used by other page sessions.
-
getTargetInfo
final TargetInfo getTargetInfo(ChromePageSession $self)
Retrieves information about this session's page target.
-
watchTargetsIn
final StateFlow<Map<String, TargetInfo>> watchTargetsIn(ChromeBrowserSession $self, CoroutineScope coroutineScope)
Watches the available targets in this browser.
-
-
-
-