How to handle a Pop up which shows up randomly while browsing website

Hello Team,

I am trying to find how I can handle a Pop up which shows up randomly while browsing the website. There is no such condition when it will show up.

There is also a chance that it may not show up at all.

Thanks,

What a terrible UX that must be. My guess, the motivation is commercial in nature, and the intent is to target “the product” (i.e the user).

My advice (which is not the best advice) would be to find the timer (a JavaScript setInterval presumably) and kill it. Job done.

In browser there’s something called Mutation Observer that lets you observe an element. Although an element not in existence is impossible to be observed directly, it is still feasible to achieve the desired result. The link above shows how.

I agree with @Russ_Thomas that you should treat this not as part of the AUT but an anomaly.
My suggestion (if you really want to down this road) is to write a Browser Extension that helps you detect where the pop-up shows up (by observing if an element with a particular ID is inserted into the page) and escapes from the pop-up automatically (by clicking on the escape button in the dialog for example). Then launch the Web Driver with this Extension installed.

Or you can discuss the removal of such a pop-up with the product owner or something.

Cheers !

@Russ_Thomas @ThanhTo Thanks for your suggestions . I will try to follow these. I got the pop up removed from test environments but Prod environment still has the same and I do run some of my test cases daily as a part of sanity.

Good.

Try this approach:

If you want me to test prod, fine, but be aware it will sometimes fail due to that crazy popup getting in the way. Why not save the setInterval handle (or whatever it is) directly on the window object, and I’ll kill from JavaScript before it gets chance to break the tests.

It might be a fixed div element which you can set display:none;width:0;height:0; on.

And as for sanity? It’s an insane thing to test! :stuck_out_tongue:

Really. If this were me, I’d say something like: “Wait. You want me to test a poorly designed thing and say it’s a pass when I’ve proved the poorly designed thing is actually a poorly designed thing. Did I get that right?”.

1 Like