Is there a way to watch for popups in Test suite level?
I tried to start a new thread to handle popup windows during the test but it didn't work.
Can someone tell me what is the problem in the following code?

void ITestModule.Run()
{
Mouse.DefaultMoveTime = 300;
Keyboard.DefaultKeyPressTime = 100;
Delay.SpeedFactor = 1.0;
Thread dialogWatcher = new Thread(ClosePopUpDialogs);
dialogWatcher.IsBackground = true;
dialogWatcher.SetApartmentState(ApartmentState.STA);
dialogWatcher.Start();
}
public static void ClosePopUpDialogs()
{
CyveraRepository.Instance.AlertWindow.SearchTimeout = new Duration(500);
while (true)
{
Report.Info("Entered while loop");
try
{
if (CyveraRepository.Instance.AlertWindow.SelfInfo.Exists() )
{
Report.Info("Found Alert Window");
Thread.Sleep(300);
Report.Screenshot(CyveraRepository.Instance.AlertWindow.Self);
CyveraRepository.Instance.AlertWindow.ButtonOk.Click();
Report.Info("Clicked OK");
Stop the running test with exit code “-1”
Report.Info("Exiting...");
Environment.Exit(-1);
}
Thread.Sleep(1000);
}
catch{}
}
}
Thanks,
Eli