mahler.protocols.element

Classes

Element

Remote browser object API.

Module Contents

class mahler.protocols.element.Element(native_element: Any, parent: Element | None = None)

Bases: Protocol

Remote browser object API.

Parameters:
  • native_element (Any) – The native element API for the underlying automation suite.

  • parent (Element | None, optional) – The parent. Defaults to None.

property parent: Element | None

The parent element this was selected from, if any.

query_selector_all(selector: str) list[Element] | None

Select all child elements of this node that match the given selector.

Parameters:

selector (str) – A CSS or XPATH selector string.

Returns:

A list of elements found, if any.

Otherwise, None.

Return type:

list[Element] | None

query_selector(selector: str) Element | None

Select the first child element of this node that matches the given selector.

Parameters:

selector (str) – A CSS or XPATH selector string.

Returns:

Found element, if any. Otherwise, None.

Return type:

list[Element] | None

click() None

Click on this element.

content() str

Return the text content of this element.

type_on(text: str, delay: float = 0) None

Emulate typing on this element.

Parameters:
  • text (str) – Text to type.

  • delay (float, optional) – Time in seconds to wait between keys. Defaults to 0.