Unexpected Popup Handling

Hello team,

I am working on an automation process that involves UI interaction with a web-based application. But sometimes, there might be a situation where some sort of warning/information/notification error might pop up in between the operation which potentially leads to the process failure.

In order to give you a picture:

→ The popup might contain an ‘X’ button to close it.

→ The popup might contain a ‘Close’ button to close it.

→ The popup might contain an ‘OK’ button to close it.

→ The popup might contain an ‘I Agree’ button to proceed.

Basically, the nature, position & characteristics of the popups are unknown.

Is there any generalized way to deal with this use case, so the popups can be tackled & the automation won’t break?

@Yoichi @supermanPunch @Palaniyappan @Anil_G

Thanks in Advance.


Use global exception handler with check app state to check for existance of any of these pop ups…if present then click and handle it …and retry current step

Else if non are found then just throw the error as any other error needs to be thrown



In the GEH, how to determine the selector of the close button if it’s unexpected? Is there any way to inject JS script to do so?

Best Regards.


We can use inject js as well…but even for that you need to determine what is the pop up type and also if pop up is present or not

Ideally…we can go with this when we identify all the pop ups that might come and then use the corresponding selectors for each of it


Hi @arjunshenoy,

We could try analysing the Selectors for each of the popup and come to a conclusion whether a Single Click could be possible with maybe Regex Expression involved within the Selectors.

Are there only 4 types of popups that appear ?

Also, Do we know at what steps do these pop ups occur or is it random ?


The popups are so random that we might not be able to get a generalized regex-based selector to handle this, given that more popups might be added later. As of now, we are getting some popups in the specific steps, which are handled right away, but announcements from the website end or any other notifications might break the automation in our case.

Best Regards.


Are all the pop ups not having a close buttom ?

If so we can generalize them into two categories…

one to click on the close button…

One to click on the first button in the pop up we get…let it be ok,I agree ,etcc…
Because generally first button will be these and the second will be cancel,no etc

So we can use two selectors in general one for click on close (x) and other for any button with idx=‘1’ instead of name or inenrtext in it

This way most of the scenarios should be handled


1 Like


Thanks for the insights. Generally speaking, most of the popups contain the ‘X’ button, will try to verify the same in my use case. If so, will go with the general selector as you suggested.

Best Regards.

1 Like

You can also consider if it is a good idea to write a handler that handles all unknown popups? Just as an example, a popup appears asking if you want to delete all the data of the transaction, and your handler clicks on “Yes”.

Of course, this is a stretched example, but it is an option to let the automation to fail until you have developed a handler for a new popup that appears.