RPA.JavaAccessBridge

Refresh application element tree

Might be required action after application element structure changes after window refresh.

Call element action

Arguments

ArgumentTypeDefault value
locatorstrnull
actionstrnull
param locator:target element
param action:name of the element action to call

Keyword to mouse click at specific coordinates.

Arguments

ArgumentTypeDefault value
xintnull
yintnull
click_typestrclick
delayfloat0.5
param x:horizontal coordinate
param y:vertical coordinates
param click_type:default click, see RPA.Desktop for different click options
param delay:how much in seconds to delay after click, defaults to 0.5

Click element

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0
actionboolTrue
timeoutint10
click_typestrclick
param locator:element to click
param index:target element index if multiple are returned
param action:call click action on element (default), or use coordinates
param timeout:timeout in seconds to find element
param click_type:default click, see RPA.Desktop for different click options

Click element of role push button

Arguments

ArgumentTypeDefault value
button_namestrnull
param button_name:name of the button to click

Close active Java window which has been accessed via `Select Window keyword.

Get list of possible element actions

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
param locator:target element

Get element text

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0
param locator:target element
param index:target element index if multiple are returned

Get matching elements

Arguments

ArgumentTypeDefault value
locatorstrnull
java_elementsboolFalse
strictboolFalse
param locator:elements to get
param java_elements:if True will return elements as JavaElement on False will return Java ContextNodes
param strict:on True all locator matches need to match exactly, on False will be using startsWith matching on non-integer properties
return:list of ContextNodes or JavaElements

Python example.

elements = java.get_elements("name:common", java_elements=True) for e in elements: print(e.name if e.name else "EMPTY", e.visible, e.x, e.y) if e.role == "check box": e.click() else: java.type_text(e, "new content", clear=True, typing=False) # following does NOT return anything because search is strict # and there are no 'push butto' role elements = java.get_elements("role:push butto", strict=True)

Robotframework example.

${elements}= Get Elements ... role:push button and name:Send ... java_elements=True Evaluate $elements[0].click() Click Element ${elements}[0] action=False Type Text ... ${elements}[0] ... moretext ... clear=True ... typing=False

Return Java locator tree as list of objects.

Mostly relevant object properties are:

  • ancestry
  • role
  • name
  • description
  • indexInParent
return:list of objects

Get Java Access Bridge version information

Highlight an element

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0
param locator:element to highlight
param index:target element index if multiple are returned

List all available Java windows.

JavaWindow object contains following properties:

  • Java process id (pid)
  • Java window title
  • Java window handle (hwnd)

The pid and title can be used to get control of the Java process by.

return:list of JavaWindow objects

Python example.

window_list = java.list_java_windows() # By looping window list for window in window_list: if window.title == "my java window title": logging.info("Java window found") java.select_window_by_pid(window.pid) # Directly accessing if len(window_list) == 1: java.select_window_by_pid(window_list[0].pid)

Robot Framework example.

@{window_list}= List Java Windows FOR ${window} IN @{window_list} IF "${window.title}" == "my java window title" Select Window By PID ${window.pid} END END IF len($window_list)==1 Select Window By PID ${window_list[0].pid} END

Press multiple keys down simultaneously

Arguments

ArgumentTypeDefault value
keysnull

See Desktop library documentation for supported keys

param keys:keys to press

Return Java table as list of lists (rows containing columns).

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
visible_onlyboolTrue

Each cell element is represented by JavaElement class.

param locator:locator to match element with type of table
param visible_only:return all the children when this is False
return:list of lists

Example.

table = java.read_table(locator_table) for row in table: for cell in row: if cell.role == "check box": print(cell.row, cell.col, str(cell.checked)) else: print(cell.row, cell.col, cell.name)

Refresh an element alone.

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0

This will ensure the latest data is available in the targeted element, thus gaining speed when dealing with big apps that won't require an entire global refresh. The obtained Java element is returned.

param locator:element to refresh
param index:target element index if multiple are returned
returns:the Java element found by the passed locator

Select menu by clicking menu elements

Arguments

ArgumentTypeDefault value
menustrnull
menuitemstrnull
param menu:name of the menu
param menuitem:name of the menu item

Selects Java application window as target for the automation using Java window title.

Arguments

ArgumentTypeDefault value
titlestrnull
bring_foregroundboolTrue
timeoutint30
param title:application window title
param bring_foreground:if application is brought to foreground or not
param timeout:selection timeout

Selects Java application window as target for the automation using Java process ID (pid).

Arguments

ArgumentTypeDefault value
pidintnull
bring_foregroundboolTrue
timeoutint30
param pid:application process id
param bring_foreground:if application is brought to foreground or not
param timeout:selection timeout

Selects Java application window as target for the automation using Java window title.

Arguments

ArgumentTypeDefault value
titlestrnull
bring_foregroundboolTrue
timeoutint30
param title:application window title
param bring_foreground:if application is brought to foreground or not
param timeout:selection timeout

Override library display scale factor.

Arguments

ArgumentTypeDefault value
factorfloatnull

Keyword returns previous value.

param factor:value for the new display scale factor
return:previous display scale factor value

Set mouse position to element center

Arguments

ArgumentTypeDefault value
elementContextNodenull
param element:target element

Call Java Access Bridge process shutdown

Toggle dropdown action on element

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0
param locator:element locator
param index:target element index if multiple are returned

Type text into coordinates defined by locator

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
textstrnull
indexint0
clearboolFalse
enterboolFalse
typingboolTrue
param locator:target element
param text:text to write
param index:target element if multiple are returned
param clear:should element be cleared before typing
param enter:should enter key be pressed after typing
param typing:if True (default) will use Desktop().type_text() if False will use Desktop().press_keys()

Wait until element(s) matching the locator are found within given timeout or raises ElementNotFound exception.

Arguments

ArgumentTypeDefault value
locatorstrnull
timeoutint10
param locator:locator to match element
param timeout:timeout in seconds to find element
return:element(s) if found

Wait until element is focused

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
indexint0
timeoutfloat0.5
param locator:target element
param index:target element index if multiple are returned
param timeout:timeout in seconds to wait, default 0.5 seconds

Wait until element text contains expected text

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
textstrnull
indexint0
timeoutfloat0.5
param locator:target element
param text:element text should contain this
param index:target element index if multiple are returned
param timeout:timeout in seconds to wait, default 0.5 seconds

Wait until element text equals expected text

Arguments

ArgumentTypeDefault value
locatorContextNode, JavaElement, strnull
textstrnull
indexint0
timeoutfloat0.5
param locator:target element
param text:element text should match this
param index:target element index if multiple are returned
param timeout:timeout in seconds to wait, default 0.5 seconds