Telerik Testing Framework includes native support for dialog handling (under the ArtOfTest.WebAii.Win32.Dialogs namespace) with built-in handlers of the common browser dialogs. The Confirm dialog is one of the covered dialogs with built-in handlers. The below code demonstrates how to implement the handler and use it to handle the dialog.
Reference the ArtOfTest.WebAii.Win32.Dialogs.dll in the project and insert it as using in the code file.
// Define the Confirm dialog and how it needs to be handled - choose between Ok and Cancel var confirmDlg = new ArtOfTest.WebAii.Win32.Dialogs.ConfirmDialog(Manager.ActiveBrowser, DialogButton.OK); // The dialog monitor is the Testing Framework built-in class for monitoring the dialogs to be handled throughout the test // Add the defined confirm dialog confirmDlg to the DialogMonitor collection and start it Manager.DialogMonitor.AddDialog(confirmDlg); Manager.DialogMonitor.Start(); // At this point when the dialog definition is added to the DialogMonitor // and it is started you can insert the action, // which triggers the confirm dialog // This is the action that invokes the dialog for this specific example // The next four lines need to be replaced for the specific application under test ActiveBrowser.Window.SetFocus(); Pages.DialogsTestingPage.ConfirmButtonTag.ScrollToVisible(ArtOfTest.WebAii.Core.ScrollToVisibleType.ElementCenterAtWindowCenter); Pages.DialogsTestingPage.ConfirmButtonTag.MouseClick(); // Here we wait for the dialog to be handled eiether specify or Settings.Current.ClientReadyTimeout will be used by default // Wait for the dialog to appear and to be handled. The WaitUntilHandled() method accepts miliseconds to define the time to wait. If no value is defined, the Settings.Current.ClientReadyTimeout is in use confirmDlg.WaitUntilHandled(); // The dialog gets automatically handled once it appears. // Remove the handled dialog from the DialogMonitor collection and stop the monitoring Manager.DialogMonitor.RemoveDialog(confirmDlg); Manager.DialogMonitor.Stop(); // Optionally, you might need to refresh the DOM used from Test Studio after the dialog was handled // The code to use for this is on the below line and will be necessary if you experience any issues with the next actions // especially if the elements to use are related to the action confirmed with the dialog handling //Manager.ActiveBrowser.RefreshDomTree();