Look for two elements, if both exist then do A, if both don't exist then do B

Hi there

new to uipath and have been going through the courses, and have a situation where I want to achieve the following:

on our software there is a OK button(element 1) I want pushed, but only if another field labelled other possible match found(element 2) does not exist. The other possible match found can be preceded by a number eg 5 other possible matches found, 1 other possible match found etc, so I am focusing that element to look for the phrase other possible.

So Scenario 1:

if Ok and this other possible exist, move onto the next page.
If OK exists and other possible doesn’t, press OK.

There are times Ok doesn’t exist at all, and to top it off, the Ok Button can appear a random amount of times on a page before, so page 1 might have none, page 2 has three, page 3 has 8 etc. I would need it to press all the OK’S that meet the requirement above on each page, and then move onto the next.

if it helps see screenshot below:

Have you tried using a pick activity, with pick branches?
Sounds like that may be a suitable path to go down, with check app state triggers depending on if your OK button is there etc.

A simpler way would be using check app state with “on element disappear” for if your ‘element 2’ does not exist. (‘Wait element vanish’ in the classic way of doing things)