Alert Handling in Web Testing

How to handle an alert when it is in a new window and if the window is not loaded fully. This window never loads successfully until unless accept/decline the alert.
image

What have you tried? What happened?

I’m not sure this will work… try calling switchToWindow* then immediately handle the alert

switchToWindowIndex
switchToWindowTitle
switchToWindowUrl