I have a foreach that deletes items from a GUI. When an item is not present in the GUI the sequence breaks. I of course want it to skip onto the next row in the item list. I have set up an Element Exists which detects whether the ‘delete’ element in present. I have this then going into an ‘IF’ but its doesn’t seem to skip.
Thanks for your help @GreenTea. I’ve now added a Boolean variable (TruFal) without a default and put this into the Element Exists output. Do I need to add some logic here:
This doesn’t skip onto the next row. The element is definitely only present when the item exist in the GUI. I see the continue activity is supposed to send the process back to the ForEach but the flow just hangs without error
okay. i’m very sorry. closer examination of the html show’s the ID is still present. The delete button disappears by changing class - I guess my question is then around how to specify class in the Element Exists’ activity
when I reverse it to False, I can see all the items in the list are flowing through and getting skipped. So I guess i’ve not configured the image properties correctly. It seems there image is generated by css
I see now. The only thing left is to assign TruFal to False inside Then block. This will reset TruFal Boolean value to False when the Delete button class cannot be detected. Thus the list will flow through and getting skipped. Hope this helps.
I think he means that you should assign False to TruFal before each round of the loop. Before Element Exists, or right after the Sequence where you click the buttons (since here, TruFal is True).
But it does not really makes sense. I mean, if TruFal is True when you check if the “A delete” Element exists, and then there is no delete button, then TruFal would be False. So there is no need to “reset” the variable.
I solved a similar problem with the Get Attribute activity. The trick is to find the right names of the attributes:
If you open the current selector of the “Element Exists: delete button” in UiExplorer (you click the three lines and then Open in UiExplorer), you can have a look at the Property Explorer (in the bottom left corner). Maybe there is an attribute there which tells you which id the button is. Maybe the id itself, maybe the text which appears when you hover it, maybe something else.
You use Get Attribute to get the value here… That will probably be a string. And you can use this in your If statement, “If buttonID.Equals(“delete”) Then do …”
Maybe a Get Text? That sometimes work, sometimes not. You can use F4 to change the selector mode and try a few different variants. And then If textFound.StartsWith(“Showing 0 of 0”) Then do…
Thanks for the help @mar.svh - i’m now trying with the Get Text - with the if statement, should it look like this? where textFound is the name of the string variable?
Yes, that was what I was meaning. It could be a good idea to put a breakpoint at the If block. Then you check the value of textFound at this point (in locals, usually on the left side in uipath studio). Sometimes, GetText takes more text than you think. Sometimes it takes nothing. It depends on the selector.
You can even use ‘Try Catch’. You can put a Try Catch inside ForEach. Keep the Click activity in Try Block. if the element is not found, it will jump to Ctach Blck. (leave the Ctach Block empty)…Further, it will repeat the same process until item is present.