Selector For Multilevel Submenu Item Click

For a java application, I need to click a dynamic (specified in an argument) menu item that is 3 levels deep.

For example, I click the following 3 menu items to ultiimately click Railroads:
Industrials-> Road & Rail-> Railroads.

I use the Find Element to locate the Railroad menu item and set Found Element output variable.
But I cannot figure out how to click this menu item when running my workflow.

How can I find and click the menu item’s Parent menu (and it’s Parent menu) or is there a an alternate way to click a submenu item without knowing it’s multilevel hierarchical path?

Additional Info:
With a one level deep submenu, I use the Get Ancestor activity to locate the target menu item’s parent and then I use the click activity to click the parent menu item first, then I use another click activity to click the desired target menu item. But a multilevel menu item has multiple ancestors, and I have not figured out how to find each one.

Hi @grosner did u tried with set focus activity?

@NIVED_NAMBIAR Thank you. The Set Focus does return the hierarchy of parents. Do I need to parse out the parent menu items and the target menu item. Do I need to iterate thru the parent menu items or is there another activity to simply click the final item?

Selector="<wnd app=‘myJavaApp.exe’ cls=‘SunAwtWindow’ idx=’*’ /><java name=‘By industry’ role=‘menu’ /><java name=‘Industrials’ role=‘menu’ /><java name=‘Road & Rail’ role=‘menu’ /><java name=‘Railroads’ role=‘menu item’ />"

Hi @grosner did set focus activity click the item directly ?

No. Set Focus did not click the element. Since the item is 3 levels deep, I cannot even see that it is actually in focus, but since the Set Focus activity is working and shows the Element property with wall the menu levels, I guess it is working. For the Set focus, I put in some delay and and also a WaitForReady.COMPLETE but that did not help.

Does the UI Element need to be visible for the Set Focus to work?

My solution for clicking a submenu that is 3 (or more) levels deep is to iterate thru each hierarchy of the menu/submenu, clicking on the correct item in each level.

I accomplished this with the following workflow activities.

  1. Attached to target window
  2. Click Activity: On top level menu dropdown. This opens the list of top level menu items
  3. Find Element Activity: Locates the target menu item. Output to varElement
  4. For each item in varElement.Selector.getTags()
  • Assign menuItem = item.Tostring()
  • Click Activity with selector set to include the menuItem variable.

The Click Activity uses the following as its selector:

“<wnd app=‘myJavaApp.exe’ cls=‘SunAwt*’ idx=’*’ />”+menuItem

Note: I had to edit the Selector Property to get menuItem variable to be part of the selector. The Selector Editor would not allow me to add this variable. If I open the Selector Expression Editor, I see the warning message “Anchor based selectors are not supported in the Selection Editor”

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.