JabRpaClient

Low-level gRPC client for the JAB server.

Wraps each RPC method defined in the jab.proto service definition. Not intended for direct use — accessed through JabDriver.

do_action

do_action(
    action: Action,
    selector: str,
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> None

Perform an accessible action on the first element matching a selector.

Parameters:
  • action (Action) –

    The Action to perform.

  • selector (str) –

    CSS-like selector string.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait, or a positive integer for max milliseconds.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    The element did not appear within the timeout.

  • JabInternalError –

    The action could not be performed.

get_actions

get_actions(
    selector: str,
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> list[jab.Action]

Get available accessible actions from the first element matching a selector.

Parameters:
  • selector (str) –

    CSS-like selector string.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait, or a positive integer for max milliseconds.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Returns:
  • list[Action] –

    List of Action objects.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    The element did not appear within the timeout.

get_info

get_info(
    selector: str,
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> jab.AccessibleInfo

Get accessible info from the first element matching a selector.

Parameters:
  • selector (str) –

    CSS-like selector string.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait, or a positive integer for max milliseconds.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Returns:
  • AccessibleInfo –

    AccessibleInfo with name, role, states, coordinates, etc.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    The element did not appear within the timeout.

get_info_from_all

get_info_from_all(
    selector: str,
) -> list[jab.AccessibleInfo]

Get accessible info from all elements matching a selector. Does not wait for a matching element, returns immediately.

Parameters:
  • selector (str) –

    CSS-like selector string.

Returns:
  • list[AccessibleInfo] –

    List of AccessibleInfo for every matching element.

  • list[AccessibleInfo] –

    Empty list if no element matches.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

get_selected_window_hwnd

get_selected_window_hwnd() -> jab.Hwnd

Return the HWND for the selected window.

Returns:
  • Hwnd –

    Hwnd message with the window handle.

Raises:
  • JabNoWindowError –

    No window has been selected yet.

get_text

get_text(
    selector: str,
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> str

Get accessible text from the first element matching a selector.

Parameters:
  • selector (str) –

    CSS-like selector string.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait, or a positive integer for max milliseconds.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Returns:
  • str –

    Accessible text content.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    The element did not appear within the timeout.

get_version_info

get_version_info() -> jab.VersionInfo

Retrieve JAB bridge and server version info.

Returns:
  • VersionInfo –

    VersionInfo if available, or None.

Raises:
  • JabNoWindowError –

    No window has been selected yet.

  • JabInternalError –

    The version info call failed.

list_java_windows

list_java_windows() -> list[jab.WindowInfo]

List all Java windows detected by the JAB server.

Returns:
  • list[WindowInfo] –

    List of WindowInfo objects with hwnd and title.

race

race(
    selectors: list[str],
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> int

Wait for any of the given selectors to match.

Parameters:
  • selectors (list[str]) –

    List of CSS-like selector strings.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait, or a positive integer for max milliseconds.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Returns:
  • int –

    Index of the first selector that matched.

Raises:
  • JabInvalidArgumentError –

    One or more selector strings are malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    No selector matched within the timeout.

refresh_tree

refresh_tree() -> None

Rebuild the cached accessibility tree on the server.

Raises:
  • JabNoWindowError –

    No window has been selected yet.

  • JabInternalError –

    The tree has no root node.

select_window

select_window(window_info: WindowInfo) -> None

Set the active window to build the accessibility tree from.

Parameters:
  • window_info (WindowInfo) –

    A WindowInfo from list_java_windows().

Raises:
  • JabInvalidArgumentError –

    The HWND does not belong to a Java window.

  • JabInternalError –

    The JAB bridge call failed.

start

start() -> None

Open an insecure gRPC channel to address:port and create the service stub.

stop

stop() -> None

Close the gRPC channel.

wait_for

wait_for(
    selector: str,
    timeout_ms: int | None,
    refresh_before_fail: bool,
) -> None

Block until an element matching the selector appears.

Parameters:
  • selector (str) –

    CSS-like selector string.

  • timeout_ms (int | None) –

    None for default (60s), 0 for no wait (fail fast), or a positive integer for max milliseconds to wait.

  • refresh_before_fail (bool) –

    If true, refresh the tree after timeout before the final check.

Raises:
  • JabInvalidArgumentError –

    The selector string is malformed.

  • JabNoWindowError –

    No window has been selected yet.

  • JabTimeoutError –

    The element did not appear within the timeout.