Closing modal that appears randomly
# i-need-help
f
Hi community, I'm having a little problem which is making my tests a little flaky due to a discount modal that is being displayed in one of the apps I'm automating. The modal is displayed in random pages after a certain period of time. I'd like to know if there is a way to create like an observer of some sort to close it if it appears in any of the tests. Would that be possible?
g
Is it completely random? And could be on any page?
f
Yes unfortunately yes
I've done it implementing a method in the
e2e.ts
file using the
Cypress.onAny()
method to detect the element and remove it.