How to handle unexpected modal box for every action in test script?

I don’t think there is a way to run a check before each Test Case step. This is going to be a difficult page to test. If I were you, I would ask the developers for a way to disable the dialog while tests are running. If that’s not possible (or they refuse) and they still insist you test it, then we’ll need to break a few rules/best practices and effect the necessary changes from JavaScript.

This is an Angular app. The div we need to control is this one:
Before:


After:

Because it’s Angular, there’s a danger that the host element is rebuilt whenever its state changes. For that reason, modifying its css properties may not work. And like you say, we don’t want to do this after each and every test step.

The only way I can think of doing this, is to use a window timer (setInterval in JavaScript).

THIS IS A TERRIBLE WAY TO TEST. (See this post).

However, if you’re stuck in this terrible position and your devs won’t give you a better way, this is what you need to do:

return setInterval(hide_SuccessModal_App, 1000);
function hide_SuccessModal_App() {
  document.querySelector("#successModal_App").style.display = "none";
}

What the code does:
Sets up a timer (setInterval) that calls a function that hides the div with id successModal_App. The timer is triggered once every 1000 milliseconds (once per second). You can of course adjust the time interval if you wish.

“Why are you returning a result from setInterval?”

If you need to, you can cancel the timer. You would pass the timer return value to clearInterval. I suspect you don’t need to do that so I didn’t include the code.

One last warning - THIS IS BAD. TRY YOUR BEST TO FIND ANOTHER WAY.

Good luck. I think you’re going to need it :confused: