JabDriver
High-level driver that manages the JAB server and provides the main entry point.
Requires a binary package to be installed (e.g. pip install jab-rpa[java8]).
JabDriver handles the full lifecycle:
- Locates the server binary (from the installed binary package)
- Spawns the
jab-rpa-server.exesubprocess - Waits for a Java window matching the given title regex
- Brings the window to the foreground and maximizes it
- Selects the window on the server to build the accessibility tree
Typical usage:
with JabDriver("MyApp.*") as driver:
loc = driver.locator("push_button[name='Clear']")
loc.wait_for()
loc.click()
__init__
__init__(
window_title: str | Pattern[str],
*,
java_bitness: Literal["32 bit", "64 bit"] = "32 bit",
java_version: Literal[
"8", "11", "17", "21", "25"
] = "8",
server_address: str = "127.0.0.1",
server_port: str = "50051",
server_timeout: int = _WAIT_FOR_SERVER_TIMEOUT,
server_step: int = _INIT_SERVER_STEP,
window_timeout: int = _WAIT_FOR_WINDOW_TIMEOUT,
window_step: int = _WAIT_FOR_WINDOW_STEP,
) -> None
Configure the driver.
| Parameters: |
|
|---|
get_version_info
get_version_info() -> VersionInfo | None
Get version info for the JAB bridge and server.
| Returns: |
|
|---|
| Raises: |
|
|---|
list_java_windows
list_java_windows() -> list[WindowInfo]
List all Java windows currently detected by the server.
| Returns: |
|
|---|
locator
locator(
selector: str,
has: list[Locator] | None = None,
require_states: set[AccessibleState] | None = None,
exclude_states: set[AccessibleState] | None = None,
) -> Locator
Build a locator to find elements in the accessibility tree.
| Parameters: |
|
|---|
| Returns: |
|
|---|
race
race(
locators: list[Locator],
timeout_ms: int | None = None,
refresh_before_fail: bool = True,
) -> int
Wait for any of the given locators to have a match.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
refresh_tree
refresh_tree() -> None
Rebuild the cached accessibility tree on the server.
Call this after UI changes (e.g. a dialog opens) so subsequent locator queries see the updated tree.
| Raises: |
|
|---|
start
start() -> None
Start the server and connect to the target window.
Spawns the JAB gRPC server, polls for Java windows whose title
matches window_title, brings the first match to the foreground,
maximizes it, and selects it on the server.
| Raises: |
|
|---|
stop
stop() -> None
Stop the client and terminate the server.
switch_window
switch_window(window_info: WindowInfo) -> None
Set the active window to build the accessibility tree from.
| Parameters: |
|
|---|
| Raises: |
|
|---|