RPA.JavaAccessBridge

Refresh application element tree

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

Call element action

Arguments

ArgumentTypeDefault valueDescription
locatorstrnulltarget element
actionstrnullname of the element action to call
param locator:target element
param action:name of the element action to call

Keyword to mouse click at specific coordinates.

Arguments

ArgumentTypeDefault valueDescription
xintnullhorizontal coordinate
yintnullvertical coordinates
click_typestrclickdefault click, see RPA.Desktop for different click options
delayfloat0.5how much in seconds to delay after click, defaults to 0.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 valueDescription
locatorContextNode, JavaElement, strnullelement to click
indexint0target element index if multiple are returned
actionboolTruecall click action on element (default), or use coordinates
timeoutint10timeout in seconds to find element
click_typestrclickdefault click, see RPA.Desktop for different click options
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 valueDescription
button_namestrnullname of the button to click
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 valueDescription
locatorContextNode, JavaElement, strnulltarget element
param locator:target element

Get element text

Arguments

ArgumentTypeDefault valueDescription
locatorContextNode, JavaElement, strnulltarget element
indexint0target element index if multiple are returned
param locator:target element
param index:target element index if multiple are returned

Get matching elements

Arguments

ArgumentTypeDefault valueDescription
locatorstrnullelements to get
java_elementsboolFalseif True will return elements as JavaElement on False will return Java ContextNodes
strictboolFalseon True all locator matches need to match exactly, on False will be using startsWith matching on non-integer properties
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 valueDescription
locatorContextNode, JavaElement, strnullelement to highlight
indexint0target element index if multiple are returned
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 valueDescription
keysnullkeys to press

See Desktop library documentation for supported keys

param keys:keys to press

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

Arguments

ArgumentTypeDefault valueDescription
locatorContextNode, JavaElement, strnulllocator to match element with type of table

Each cell element is represented by JavaElement class.

param locator:locator to match element with type of table
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)

Select menu by clicking menu elements

Arguments

ArgumentTypeDefault valueDescription
menustrnullname of the menu
menuitemstrnullname of the menu item
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 valueDescription
titlestrnullapplication window title
bring_foregroundboolTrueif application is brought to foreground or not
timeoutint30selection timeout
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 valueDescription
pidintnullapplication process id
bring_foregroundboolTrueif application is brought to foreground or not
timeoutint30selection timeout
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 valueDescription
titlestrnullapplication window title
bring_foregroundboolTrueif application is brought to foreground or not
timeoutint30selection timeout
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 valueDescription
factorfloatnullvalue for the new display scale factor

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 valueDescription
elementContextNodenulltarget element
param element:target element

Call Java Access Bridge process shutdown

Toggle dropdown action on element

Arguments

ArgumentTypeDefault valueDescription
locatorContextNode, JavaElement, strnullelement locator
indexint0target element index if multiple are returned
param locator:element locator
param index:target element index if multiple are returned

Type text into coordinates defined by locator

Arguments

ArgumentTypeDefault valueDescription
locatorContextNode, JavaElement, strnulltarget element
textstrnulltext to write
indexint0target element if multiple are returned
clearboolFalseshould element be cleared before typing
enterboolFalseshould enter key be pressed after typing
typingboolTrueif True (default) will use Desktop().type_text() if False will use Desktop().press_keys()
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 valueDescription
locatorstrnulllocator to match element
timeoutint10timeout in seconds to find element
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 valueDescription
locatorContextNode, JavaElement, strnulltarget element
indexint0target element index if multiple are returned
timeoutfloat0.5timeout in seconds to wait, default 0.5 seconds
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 valueDescription
locatorContextNode, JavaElement, strnulltarget element
textstrnullelement text should contain this
indexint0target element index if multiple are returned
timeoutfloat0.5timeout in seconds to wait, default 0.5 seconds
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 valueDescription
locatorContextNode, JavaElement, strnulltarget element
textstrnullelement text should match this
indexint0target element index if multiple are returned
timeoutfloat0.5timeout in seconds to wait, default 0.5 seconds
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