How to handle random popup

I am doing automation for application, Where I am getting one popup randomly, there is no fix pattern. Whenever that popup will appear I have to click on “Close” good part is its selector is always same.

Can anyone suggest how to handle this type of popup, One thing I can think is to create one workflow and include after every activity. but its not a good approach I think.

Please suggest best approach to handle this.


How about use paralel activity and your logic in one Sequence and On Element Appears in another sequence? You need to add timeout to your activities so the On Element activity will buy some time to click on the pop up. This is just an idea.


Beside from the good suggestion from @vvaidya, remember that a programmer did that procedure, so you might be able to track the behavior. have you? I’ts difficult for me to find a class named “Random popup” :slight_smile:-

I remember a case downloading PDF’s, where it was a pop up window "when the PDF had more than one sheet" , - basically the invoice had in like 90% of the times 1 sheet, in that time I read Design patterns, and decided to encapsulate that part (the 10% left), I have to say that you will draw your workflow first.

regards, and happy automation!.

Yes, I have track behavior this is depends on session of current user in our application. when same user is logged in to different system then we’re getting this popup.

Parallel activity may help but my mouse focus will be changed from other parallel activity which I will use to close popup when it will appear.

I see, I think that you could do the process normally and just use a try catch and then on the exception click to close the pop up and then manage to continue where you left the process, or start over, you’ll have to determine what is the best solution for this case. What you think?

If your process doesn’t expect other pop ups, how about block/unblock pop ups for just the process.

IE —> ALT+TPB – Block/Unblock


This is the approach I am thinking of, but problem is it will take lots of time to put exception handling for each activity.

That is expected popups, if we ignore those popup it will affect user’s session.

Yes. It will be too complicated to use lots of try-catches.

Aside Parallel it seems it makes sense to create an activity called PopupScope. Before going to the next instruction within PopupScope it will permanently check if we have a popup on the screen plus it will contain instruvtions on how to handle the popup (click ok, click cancel, etc).

@badita - Do you mean to create custom activity “PopupScope”? OR we can use any existing activity like “Element scope”?

@uipath to create :slight_smile:

ok… Thanks :slight_smile:

Have you tried using continue on error?

many TryCatch, not really, I think more like, since I had the same synthom when somebody else connect to the webpage to download invoices, I was downloading an invoice lets say IP0001, then on the P1002 the pop up appears, what I did is a try catch. try to download invoice P1002 and if there’s any error click the popup and “end” the process, now, outside the try catch What I had it was an state machine to read in a config file which invoices the robot was able to download and put a log on a certain row, and then since the process stoped on P1002 this row would not have the log, so it will start from there again.

What do you think, I guess I can send you the XAML for your reference if you have doubts on how to implement this. :slight_smile:

Continue on error for every element is also not a good option. Because If flow will continue on error then it will not do work what I indent to do.

Thanks @beesheep I understood your scenario and I’ve implemented try catch at few places, but my situation is popup randomly comes in between the activity I am doing hundreds of activity

My situation can be solved if I do below

  • If i create one workflow to close popup if its available and include between every activity.


  • Inovke Popup close workflow
  • Activity 1. e.g. Click on element
  • Invoke Polpup Close Workflow
  • Activity 2. Type text
  • Invoke Popup Close Workflow
  • Activity N…

first add “image exists” then assign a variable to it and then use decision flow activity, in “image exists” give the image of popup, and in the decision flow , in true part use click activity (to close the popup). try this and it should work. :slight_smile:

@yashvardhan_singh - This approach can work if popup 's pattern is fixed, in my case popup can come in between of screen any time.

Hi @badita,

Would you know if @uipath is planning to implement the “PopupScope” activity you mentioned here?