Tab
Represents a browser tab, which is a connection to a specific target in the browser.
This class provides methods to interact with the tab, such as navigating to URLs, managing history, evaluating JavaScript expressions, and manipulating the DOM.
You can create a new instance of this class using the dev.kdriver.core.browser.Browser.get method:
fun main() = runBlocking {
val browser = createBrowser(this)
val tab = browser.get("https://example.com")
// Use the tab instance to do things...
browser.stop()
}
Inheritors
Properties
Functions
Adds a handler for a specific CDP event.
Brings the tab to the front, activating it.
Internal method to call a CDP command.
Disables the DOM agent to stop receiving DOM-related events.
Expects a request to match the given urlPattern.
Returns elements which match the given text. Please note: this may (or will) also return any other element (like inline scripts), which happen to contain that text.
Sets the tab's window to fullscreen mode.
Gets all elements of tag: link, a, img, script, meta.
Convenience function, which returns all links (a, link, img, script, meta).
Gets the content of the tab as a string.
Gets the current window information for the tab.
Intercepts network requests matching the given urlPattern and requestStage. This allows you to modify requests, responses, or block them entirely.
Performs a native mouse click at the specified \[x, y\] coordinates.
Finds a single element based on a CSS selector string.
Equivalent of JavaScript's document.querySelectorAll
. This is considered one of the main methods to use in this package.
Evaluates a JavaScript expression in the context of the tab.
Saves a screenshot of the page. This is not the same as Element.saveScreenshot, which saves a screenshot of a single element only.
Takes a screenshot of the page and returns the result as a base64 encoded string. This is not the same as Element.screenshotB64, which takes a screenshot of a single element only.
Scrolls the tab down by a specified amount.
Sets the user agent for the tab.
Updates the target information by fetching it from the CDP.
Waits for the document's ready state to reach a specified state.