With a Java SunAWTFrame app, the Click activity fails when clicking on element that is a node in a JTree. The JTree is contained in a JViewPort. The Click fails while attempting to click on a selector (element), if a portion (where selector can be seen) of the JViewPort is off-screen.
If the JViewPort is entirely on-screen, then the Click activity works as expected
- Find Element successfully finds the Jtree node’s target and saves it to a variable (foundNode).
- Click (target = foundNode) activity FAILS with message:
Click: Cannot send input to UI element because it is outside of screen bounds.
- A portion of JViewPort and target element are located outside screen bounds.
- Or the window was resized and obscures the UI Element from the human eye.
- When the JViewPort and target element are both located inside screen (and window) bounds, then the click will work.
The application’s window was positioned so half of the window (and JViewPort) is offscreen (see image).
In this Scenario, the UI element is always visible when the window is maximized.
Using an Anchor does not help.
Simulate Click does not work with this Java application
The Select Item activity does successfully select an item in the JTree, even when not visible to the human eye.
Using UiPath.UIAutomation.Activities 21.10.3
I can workaround the issue using either of these techniques:
Maximize the window:
- Maximizing the window and ensure the entire JViewPort and target item is visible on screen.
Use the Select Item and Type Into Activities
- Select Item target: <java cls=‘JTree’ role=‘tree’ />
- Select Item To Select: String variable or the exact text in the JTree to select.
- Fix the Click activity so that If an element (i.e. selector) can be found (using Find Element), then the same selector it should be clickable, EVEN WHEN offscreen.
If Find Element can successfully locate a selector, then Click should also work.
Alternatively, perhaps the UiPath.UIAutomationNext.Activities.NSelectItem (that, unlike click, does work to select an offscreen element) can include an option to automatically make uielement visible onscreen (either before or after the select activity.