If any error while running sequence then i want run next loop

Hi All,

I want to run the bot in a for each loop if an element is not found even though the Bot should run for the next iteration and should not fail. How can we do this.

1 Like

Use check app state or element exists activity and get the boolean value as output

Then use a IF activity where if the above boolean is true it guess to then block or to else block

Or simply you can enable CONTINUE ON ERROR PROPERTY to continue even if any Ui automation activity fails like click or type into etc

Hope this helps

Cheers @SURESH_P

An automation like this it’s better to use a FlowChart to loop around than a For Each. I suggest looking at the Transactional Process template for an idea how to do this.


  1. use check app state and if cot foudn continue
  2. use try catch around the actvities inside loop and in catch do nothing



  1. For Each Loop: Create a “For Each” loop activity in your UiPath workflow to iterate through a collection or a list of items.
  2. Try Catch: Inside the loop, add a “Try Catch” activity. This will handle any exceptions that may occur during the execution of the activities within the loop.
  3. Activities to Find Element: Within the “Try” block of the “Try Catch” activity, place the activities that are supposed to find the element. For example, you might use activities like “Find Element,” “Click,” or any other activities related to interacting with the element you’re searching for.
  4. Catch Block: In the “Catch” block of the “Try Catch” activity, you can catch and handle exceptions. However, in this case, you don’t necessarily need to do anything specific to handle the exception. You can leave the “Catch” block empty or add a log message for reference.
  5. Continue On Error: Make sure the “ContinueOnError” property of the activities within the “Try” block is set to True. This allows the bot to continue to the next iteration of the loop even if the element is not found, and an exception is thrown.
  6. Loop Logic: Continue with the rest of your loop logic, which will execute for each iteration, regardless of whether an element was found or not.
  1. Set Up a For Each Loop:
  • Drag and drop a “For Each” activity into your workflow.
  • Configure it to iterate over your collection or data source.
  1. Add a Sequence Inside the For Each Loop:
  • Within the “For Each” activity, add a Sequence activity where you’ll place your bot logic.
  1. Add Bot Logic to Search for the Element:
  • Inside the Sequence, add your bot logic to search for the element.
  1. Use Try-Catch Block:
  • Wrap your bot logic with a Try-Catch block to handle exceptions.
  • Drag and drop a “Try Catch” activity around your bot logic.
  1. Handle Element Not Found:
  • Inside the Catch block, add activities to handle the case where the element is not found. You might want to log the error or perform any other necessary actions.
  1. Continue to the Next Iteration:
  • After handling the exception, you can use a “Continue” activity to jump to the next iteration of the loop.
  • Place the “Continue” activity at the end of the Catch block.