Could someone please explain how to use the “For Each UI Element” activity?
【What I want to automate】There is a screen in a SaaS application with the following features:
・A screen for managing training courses displays the current list of courses.
・This list changes dynamically (courses are added or deleted).
・Each course has a menu button. Clicking it displays a pop-up menu.
・Click “Export data” in the pop-up menu to export the data.
【Question】
・I was able to display the pop-up menu for each course by specifying the menu buttons in the courses with the “For Each UI Element” activity and setting “Current Element” as the input element for the “Click” activity. However, clicking “Export data” in the pop-up menu succeeds for the first item, but fails from the second item onward.
I also couldn’t move the cursor down within the menu.
How can I click an item in the pop-up menu associated with the current element? I’m a beginner, so please excuse me if this is a basic question.
What error message are you seeing?
I suspect it may be due to a selector mismatch. If so, we can investigate the cause based on the mismatch information.
In debugging, the activity for clicking “Export” in the pop-up menu appears to complete successfully (but in reality, no click is performed). Then, at the activity for clicking “Output” in the next pop-up screen for exporting, it STOPs with “[Target]: Strict selector failure:”
In that case, I suggest first changing the click input method to “Hardware Event” and checking whether the click succeeds and whether the mouse moves to the expected location.
After changing the input mode for clicking “Export” in the popup menu to Hardware Events,
this activity now stops with the following error. (The second popup menu is displayed.)
[Error] Click ‘Export (Question)’: Cannot send input to a UI element that is outside the screen boundaries.
The situation has changed a little.
When I changed the click on “Export” in the popup menu from a strict selector to image-only (with the input mode set to Hardware Events), it clicked each training item as intended. However, it still isn’t completely resolved because it errors on training items that aren’t visible and require scrolling.
I’d like to ask about something: Since the loop (For Each UI Element) repeats the execution section, I don’t understand what you meant by “comparing the first and second popup selectors.” They use the same Click activity, so what exactly should I compare?
I think the tricky part is that each course has its own pop-up menu, so the selector for “Export data” may need to be refreshed for every iteration. You could try using a dynamic selector or finding the menu item relative to the current UI element. Also, adding a short delay or checking that the menu is fully visible before clicking might help. Hope you get it working!
If you need precise behavior, it’s probably best not to use fuzzy selectors.
I’d recommend checking in UiExplorer for other attributes that can identify the element. If you find any, use them to specify a dynamic selector; if not, use idx in a dynamic selector.