mahler.protocols.window

Classes

Window

Remote browser interactive API.

Module Contents

class mahler.protocols.window.Window(model: Literal['chrome', 'firefox'], headless: bool = True, enable_javascript: bool = True, fingerprint: mahler.fingerprint.Fingerprint | None = None)

Bases: Protocol

Remote browser interactive API.

Parameters:
  • model (Literal["chrome", "firefox"]) – Browser type.

  • headless (bool, optional) – Run in headless mode. Defaults to True.

  • enable_javascript (bool, optional) – Enable JavaScript in browser. Defaults to True.

  • fingerprint (Fingerprint | None, optional) – Browser fingerprint to apply, if any. Defaults to None.

goto(url: str, timeout: float | None = None) None

Navigate to a URL.

Parameters:
  • url (str) – URL to visit.

  • timeout (float | None, optional) – Time in seconds to let load. Defaults to None.

query_selector_all(selector: str) list[mahler.protocols.element.Element] | None

Select all elements on the page 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) mahler.protocols.element.Element | None

Select the first element on the page 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