How to handle random popups/modal both web and native apps?

Hi all,

I need a solution to interact and close random popups appearing during the test execution.
I don’t want to use waits (both implicit or explicit), or try/catch. I would like a solution with something like a java thread living in background that’s along the test execution, that’s checks for popup presence in foreground and, if visible, close it.

Is there any solution available on TP (even framework code approach)?

Thanks

@primop got any solution? Looking for the same