Do While Loop Examining Two Conditions

I’m running a do while loop with a try catch inside of it.
I want it to keep doing the process until the submit button is found, or until the exceptionCounter is equal to 2.
I only want it to try the process twice, and if it doesn’t work I want it to throw an exception, and shut down the whole workflow.

I can’t seem to get my condition statement right.
The two conditions are

No SubmitFound OR exceptionCounter <=2

So I want it to keep doing the loop if the Submit Button is not found, or at try it twice.

When I do that, it just keeps going and going and going. It never breaks out of the loop.

I’m assuming this is because it examines this statement and it see’s that the submit button was never found, even though exceptionCounter is not less than or equal to 2 any more, and it has surpassed it making that statement false, NOT submitFound is still true, so it just keeps going.

So how am I going to do this.

Here is my workflow. It’s for completing ticketing. Sometimes it freezes up and doesn’t go to the next page where the submit button is found. So it tries to re start, and if it’s still freezing up, it just closes everything out.

Test1.xaml (22.3 KB)

I think you should use an AND with a negate and not an OR

If not found within retries:

  1. Default submitFound= False ,exceptionCounter =1
  2. While 1: Not submitFound(false) AND exceptionCounter<=2 evaluates to True
  3. Retry, exceptionCounter = exceptionCounter +1
  4. While 2: Not submitFound(false) AND exceptionCounter <=2 evaluates to True
  5. Retry, exceptionCounter = exceptionCounter +1
  6. While 3: Not submitFound(false) AND exceptionCounter <=2 evaluates to False
  7. Exits

If Found within retries:
While: Not submitFound(true) AND exceptionCounter <=2 evaluates to False

Here is your xaml Test.xaml (23.9 KB)
Tested(with simulation) and it works fine

Let me know if it works for you.

What I ended up doing was different, but that is the answer to the question I asked.
I have to end the program, so I stayed in the loop until exceptionCounter <=2
Then once out of the loop I examine if the submit button was ever found, and if it wasn’t I throw an exception.

If you use AND then both of the statements have to be true before it will break out of the loop. So if the submit button is found on the first go round, it will just keep going until exceptionCounter reaches 2 right?

Actually…What I did didn’t solve it, because if I say, do this until the ExceptionCounter is 2, then it’s going to run through it twice anyways.

Hi there. I suggest using the Retry Scope. You won’t need to use a counter and it will only retry a certain number of times. Then, use the Element Exists or Is True in the condition part of the Retry Scope; it will retry until the condition is true or hits the number of retries that was set. (also, usually you want to set the time before retries to 00:00:00 unless you need a delay for some reason.

1 Like

No, it will exit as we are using a Not before the found.
See generally with elementExists the output is false if not found. In that way if you see the logic it will exit if found and continue for 2 times if not found then exit.

See, it will do once without the condition check and the counter become 2 if exception/notfound
it will try again and then if exception/notfound counter becomes 3 and it will exit.

And a retry scope is also suitable as Clayton mentioned.

1 Like