I am trying to follow the step @ http://www.ranorex.com/blog/handling-di ... up-windows
But can't figure out where to start another thread and where does this code goes to:
Report.Info("Start simulating pop ups by pressing the 'Start' button.");
repo.AppDialogSimulator.ButtonStart.Click();
// Creates and starts a new thread
// which handles unexpected dialogs
Thread dialogWatcher = new Thread(ClosePopUpDialogs);
dialogWatcher.Start();
Report.Info("Start simulating pop ups by pressing the 'Start' button.");
repo.AppDialogSimulator.ButtonStart.Click();
// Creates and starts a new thread
// which handles unexpected dialogs
Thread dialogWatcher = new Thread(ClosePopUpDialogs);
dialogWatcher.Start();The new thread called “dialogWatcher” executes the so-called “ClosePopUpDialogs” method, which does the job of closing the dialogs once they pop up:
view plaincopy to clipboardprint
public static void ClosePopUpDialogs()
{
while (true)
{
if (repo.Dialog_01.SelfInfo.Exists() )
{
Thread.Sleep(300);
Report.Screenshot(repo.Dialog_01.Self);
repo.Dialog_01.Yes.Click();
}
if (repo.Dialog_02.SelfInfo.Exists() )
{
Thread.Sleep(300);
Report.Screenshot(repo.Dialog_02.Self);
repo.Dialog_02.Retry.Click();
}
if (repo.Dialog_03.SelfInfo.Exists() )
{
Thread.Sleep(300);
Report.Screenshot(repo.Dialog_03.Self);
repo.Dialog_03.Close.Click();
}
Thread.Sleep(1000);
// Check if the 'Start' button's enabled state is set to true
// The 'Enabled' property is used to determine whether
// the simulation has been stopped manually by the user
if (repo.AppDialogSimulator.ButtonStart.Enabled == true )
{
Report.Info("Simulation was interrupted manually");
Report.Screenshot(repo.AppDialogSimulator.Self);
break;
}
}
}