or
public override void OnBeforeTestStarted() { AlertDialog myAlertDialog = new AlertDialog(ActiveBrowser, DialogButton.OK); myAlertDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler); //Manager.DialogMonitor.AddDialog(new AlertDialog(ActiveBrowser, DialogButton.OK)); Manager.DialogMonitor.AddDialog(myAlertDialog); Manager.DialogMonitor.Start(); } public void MyCustomAlertHandler(IDialog dialog) { // Simply close the dialog System.Threading.Thread.Sleep(1500); System.Drawing.Bitmap image = Manager.ActiveBrowser.Capture(); //System.Drawing.Bitmap image = Manager.ActiveBrowser.Window.GetBitmap(); image.Save(this.ExecutionContext.DeploymentDirectory.ToString() + @"\Data\alert.png", System.Drawing.Imaging.ImageFormat.Png); dialog.Window.Close(); try { // Wait until it is closed dialog.Window.WaitForVisibility(false, 50); Log.WriteLine("Alert Handled!"); } catch { Log.WriteLine("Failed to handle alert!"); } }public static class PCCSR { public static string root = ExecutionContext.Current.DeploymentDirectory + @"\Data\"; public static void NSRtestWPF() { Manager.Current.LaunchNewApplication(root + @"PCCNSR.exe", "Admin"); ListBox b = Manager.Current.ActiveApplication.MainWindow.Find.ByName<ListBox>("lstbxFiles"); Assert.IsTrue(b.Items.Contains("Baseline_Security_Roles_Admin.csv"), "File not found"); } }