Test suite level Popup Watcher

Ask general questions here.
elis
Posts: 15
Joined: Sun Nov 10, 2013 10:27 am

Test suite level Popup Watcher

Post by elis » Sun Dec 15, 2013 2:40 pm

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Test suite level Popup Watcher

Post by Support Team » Tue Dec 17, 2013 4:41 pm

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)