Page 1 of 1

Test suite level Popup Watcher

Posted: Sun Dec 15, 2013 2:40 pm
by elis
Hi all,

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? :lol:

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

Re: Test suite level Popup Watcher

Posted: Tue Dec 17, 2013 4:41 pm
by Support Team
Hello elis,

Please try to add a short delay (e.g. 1000ms) after you start the PopupWatcher thread.
This would allow Ranorex to have time to run your 'ClosePopUpDialogs' method before the test is finished.
Thread dialogWatcher = new Thread(ClosePopUpDialogs);
dialogWatcher.IsBackground = true;
dialogWatcher.SetApartmentState(ApartmentState.STA);
dialogWatcher.Start();

Delay.Milliseconds(1000);
Regards,
Markus (T)