For Each UI Element Fails in Debug Mode

The For Each UI Element activity works correctly when the workflow is executed in Run mode. However, when executed in Debug mode, it throws the following error:

“[Target]: Could not find the UI element corresponding to this selector:
[1] webctrl id=‘caretsiframe’ tag=‘IFRAME’
[2] webctrl class=‘jspPane’ parentid=‘caretsCont’ tag=‘DIV’
Search failed at selector tag:
[1] webctrl id=‘caretsiframe’ tag=‘IFRAME’

For Each UI Element ‘08152024 MCEXAM Diaz,…’: Could not find the user-interface (UI) element for this action.”

I am looking for the correct approach to resolve this issue.

Thanks in advance

@jai_kumar2

First check the selector for any dynamic parts

second are you sure its failing in debug and no error in run? because in run mode even if there is error it would move forward..to confirm in debug click continue and check

also one way is to use check app state before for each ui element

cheers

1 Like

try this
1 Add a wait before looping
2 stablize the iframe selector
3 use attach browser/ window inside the loop

This issue happens because Debug mode changes the timing and focus, causing the UI element (especially inside an IFRAME) to load later than it does in Run mode.
The selector is valid, but Debug mode often pauses before the IFRAME is fully loaded, so the activity cannot find it.

Hi,
Use Find Children Instead of For Each UI Element

Find Children can fetch all elements inside a container without immediately interacting with them.

Steps:

  1. Attach to the IFRAME.
  2. Use Find Children on the container DIV to get a list of elements.
  3. Iterate over that list in a regular For Each loop.
  1. Set WaitForReady = COMPLETE and DelayBefore 500–1000 ms in For Each UI Element.

  2. Wrap the loop inside Attach Browser / Use Application Browser.

  3. Use Switch to Frame to enter the correct iframe before looping.

  4. If still unstable, replace with Find Children → loop through output.

  5. Debug mode is slower, so these steps ensure iframe + UI loads fully before selector search.