DefaultElement

open class DefaultElement(val tab: Tab, var node: DOM.Node, var tree: DOM.Node? = null) : Element

Default implementation of the Element interface.

Constructors

Link copied to clipboard
constructor(tab: Tab, node: DOM.Node, tree: DOM.Node? = null)

Properties

Link copied to clipboard
open override val attrs: List<String>

Returns a list of attributes of the element.

Link copied to clipboard
open override val backendNodeId: Int

The internal node ID of the element in the DOM tree.

Link copied to clipboard
open override val children: List<Element>

Returns the elements' children. Those children also have a children property so you can browse through the entire tree as well.

Link copied to clipboard
open override var node: DOM.Node

The underlying DOM node representing this element.

Link copied to clipboard
open override val nodeType: Int
Link copied to clipboard
open override val objectId: String?
Link copied to clipboard
open override val parent: Element?
Link copied to clipboard
open override val parentId: Int?
Link copied to clipboard
val tab: Tab
Link copied to clipboard
open override val tag: String

The name of the tag of the element, in lowercase.

Link copied to clipboard
open override val text: String

The text content of the element, which is the concatenation of all text nodes within the element, excluding any HTML tags.

Link copied to clipboard
open override val textAll: String

Gets the text contents of this element, and it's children in a concatenated string NOTE: this includes text in the form of script content, as those are also just 'text nodes'

Link copied to clipboard
open override var tree: DOM.Node?

The DOM tree in which this element resides.

Functions

Link copied to clipboard
inline suspend fun <T> Element.apply(jsFunction: String, awaitPromise: Boolean = false): T?

Applies a JavaScript function to the element and returns the result. The given js_function string should accept the js element as parameter, and can be a arrow function, or function declaration.

Link copied to clipboard
open suspend override fun clearInput()

Clears the input of the element by setting its value to an empty string.

Link copied to clipboard
open suspend override fun clearInputByDeleting()

Clears the input of the element by simulating a series of delete key presses.

Link copied to clipboard
open suspend override fun click()

Clicks the element, simulating a user click.

Link copied to clipboard
open suspend override fun focus()

Focuses the element, making it the active element in the document.

Link copied to clipboard
open operator override fun get(name: String): String?

Returns the value of the attribute with the given name, or null if it does not exist.

Link copied to clipboard
open suspend override fun getPosition(abs: Boolean): Position?

Retrieves the position of the element in the viewport.

Link copied to clipboard
open suspend override fun insertText(text: String)

Inserts text into the element, simulating user input.

Link copied to clipboard
open suspend override fun mouseMove()

Moves the mouse to the center of the element and simulates a mouse click.

Link copied to clipboard
open suspend override fun querySelector(selector: String): Element?

Finds the first descendant element matching the given CSS selector, similar to JavaScript's querySelector().

Link copied to clipboard
open suspend override fun querySelectorAll(selector: String): List<Element>

Finds all descendant elements matching the given CSS selector, similar to JavaScript's querySelectorAll().

Link copied to clipboard
open suspend override fun rawApply(jsFunction: String, awaitPromise: Boolean): JsonElement?

Applies a JavaScript function to the element and returns the result. The given js_function string should accept the js element as parameter, and can be a arrow function, or function declaration.

Link copied to clipboard
open suspend override fun sendFile(paths: List<Path>)

Sends a list of file paths to the element, simulating a file input.

Link copied to clipboard
open suspend override fun sendKeys(text: String)

Sends a sequence of keys to the element, simulating user input.

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String

Returns a string representation of the element, including its tag name, attributes, and content.

Link copied to clipboard
open suspend override fun update(nodeOverride: DOM.Node?): Element

Updates the element to retrieve more properties, such as enabling the children and parent attributes.

Link copied to clipboard
open suspend override fun updateRemoteObject(): Runtime.RemoteObject?