or
Is in telerik testing framework something to restart the test?
Settings settings =
new
Settings();
settings.Web.DefaultBrowser = ArtOfTest.WebAii.Core.BrowserType.FireFox;
settings.UnexpectedDialogAction = UnexpectedDialogAction.DoNotHandle;
Manager manager =
new
Manager(settings);
manager.Start();
manager.LaunchNewBrowser();
manager.DialogMonitor.Start();
// Setup dialog monitoring.
AlertDialog alertDialog = AlertDialog.CreateAlertDialog(manager.ActiveBrowser, DialogButton.OK);
manager.DialogMonitor.AddDialog(alertDialog);
// Set new browser tracking to enabled.
// This will make all new browser instances connect to the Manager.
manager.SetNewBrowserTracking(
true
);
manager.ActiveBrowser.NavigateTo(
"http://localhost:60444/ConduitGenericWebSite/Default.aspx"
);
Element confButton = manager.ActiveBrowser.Find.ById(
"lnkShowPopup"
);
(
new
HtmlControl(confButton)).Click();
// Wait for the new browser instance to connect.
manager.WaitForNewBrowserConnect(
"http://localhost:60444/ConduitGenericWebSite/ChildPage.aspx"
,
true
, 10000);
// disable new browser tracking
manager.SetNewBrowserTracking(
false
);
// Click to invoke AlertDialog.
Element confButton1 = manager.ActiveBrowser.Find.ById(
"lnkShowConfirmAndAlert"
);
(
new
HtmlControl(confButton1)).Click(
true
);
alertDialog.WaitUntilHandled(3000);
public void DoCustomDialogHandlingForBuiltInDialogs()
{
AlertDialog myAlertDialog = new AlertDialog(ActiveBrowser, DialogButton.OK);
myAlertDialog.HandlerDelegate = new DialogHandlerDelegate(MyCustomAlertHandler);
// Add dialog to monitor and start monitoring
Manager.DialogMonitor.AddDialog(myAlertDialog);
Manager.DialogMonitor.Start();
Actions.InvokeScript("InvokeAlert()");
}
///<
summary
>
/// Custom dialog handler delegate
///</
summary
>
///<
param
name
=
"dialog"
>The dialog to handle</
param
>
///<
returns
></
returns
>
public bool MyCustomAlertHandler(IDialog dialog)
{
// Simply close the dialog
dialog.Window.Close();
try
{
// Wait until it is closed
dialog.Window.WaitForVisibility(false, 50);
Log.WriteLine("Alert Handled!");
return true;
}
catch
{
Log.WriteLine("Failed to handle alert!");
// return false if the dialog did not close as expected
return false;
}
}