Skip to main content

Python implementation for Java application UI automation with Java Access Bridge

Project description

Python implementation for Java application UI automation with Java Access Bridge.

The pyjab package enables run UI automation(selenium like) through with Java UI application. Package will invoke Java Access Bridge API to get information form Java application. And this package is only support for Windows. Sources code referenced from NVDA.

Installation

The pyjab package is available on PyPI which means installation should be as simple as:

$ pip install pyjab

There’s actually a multitude of ways to install Python packages (e.g. the per user site-packages directory, virtual environments or just installing system wide) and I have no intention of getting into that discussion here, so if this intimidates you then read up on your options before returning to these instructions.

Optional dependencies

Access Bridge Explorer is a Windows application that allows exploring, as well as interacting with, the Accessibility tree of any Java applications that uses the Java Access Bridge to expose their accessibility features, for example Android Studio and IntelliJ.

Usage

JRE, JDK or JAB standalone package is required. Need setup environment variable JAVA_HOME or JAB_HOME before usage.

Here’s an example of how easy it is to get started:

from pyjab.jabdriver import JABDriver

# Create a JABDriver object.
jabdriver = JABDriver("java app window title")

# Find a JABElement by element name
login_btn = jabdriver.find_element_by_name("Login")

# Click a JABElement
login_btn.click()

# Some other examples.
jabdriver.find_element_by_xpath("//push button[@name=contains('OK')]")
jabdriver.wait_until_element_exist(by=By.NAME, value="Dashboard")
login_btn.get_screenshot_as_file("./screenshot.png")

You may also use a context manager approach to kill the Java Window after the JABDriver is cleared:

from pyjab.jabdriver import JABDriver

# Create a JABDriver object.
with JABDriver("java app window title") as jabdriver:

    # Find a JABElement by element name
    login_btn = jabdriver.find_element_by_name("Login")

    # Click a JABElement
    login_btn.click()

You can also open the Java window process by specifying the file path which will launch the Java WebStart process for the given file :

from pyjab.jabdriver import JABDriver

# Create a JABDriver object.
with JABDriver(title="java app window title", file_path="C:\\jnlps\\test.jnlp") as jabdriver:

    # Find a JABElement by element name
    login_btn = jabdriver.find_element_by_name("Login")

    # Click a JABElement
    login_btn.click()

Contact

The latest version of pyjab is available on PyPI and GitHub. For bug reports please create an issue on GitHub. If you have questions, suggestions, etc. feel free to send me an e-mail at gaozhao89@qq.com.

License

This software is licensed under the GPLv2 license.

© 2021 Gary Gao.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyjab-1.1.7.tar.gz (38.4 kB view hashes)

Uploaded Source

Built Distribution

pyjab-1.1.7-py2.py3-none-any.whl (40.5 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page