UiPath Community version 2020.4.3 losing context of variables while iterating in a loop

I working an exercise in community version and iterating through a For Each loop. When I run in debugger with a breakpoint at the start of each iteration the code runs fine. However when I try to run out side of the debugger the variable lose the context they had and i get an “invalid UI Node” error when the code tries to read a variable with should contain a UiElement within an array. The array is empty after the first iteration but contained 2 elements when first initialized. Has anyone seen this sort of behavior? Again it works fine if I step through the code in debugger but fails when run outside of debugger.

Not sure this will help, but perhaps the method you are using to store the selector as a variable is too fast and not working correctly, include some writelines with variable value after assigned to see if it what you intended. Note the debugger runs slower so sometimes timing issues can cause unforeseen effects.

1 Like

Thanks Matt - I have tried the writes and peppering with Delays thinking it is a speed sort of issue but the delays are not impacting outside of taking longer for the next activity to trigger.

Well after replying i took another look at what I was writing and focused on writing the array element it seems to be breaking on. When I did that it made progress until the number of elements in the array increase it then breaks again with invalid UI node. I feel like I have something to go on now so appreciate the help.