Hi Madhav,
Yes. Here is a complete working sample test:
[TestMethod]
public
void
VerifyAlertDialogText()
{
// Load our webpage in the browser
Manager.LaunchNewBrowser();
// Initialize custom 'Alert' dialog handler
AlertDialog alertDialog =
new
AlertDialog(ActiveBrowser, DialogButton.OK);
alertDialog.HandlerDelegate = MyCustomAlertHandler;
Manager.DialogMonitor.AddDialog(alertDialog);
// Click that
ActiveBrowser.Frames[
"view"
].RefreshDomTree();
ActiveBrowser.Frames[
"view"
].Find.ByExpression<HtmlInputButton>(
"value=Show alert box"
,
"tagname=input"
).Click();
// Wait Until Dialog is Handled.
alertDialog.WaitUntilHandled(5000);
}
/// <summary>
/// Custom alert dialog hander to read and verify the text
/// </summary>
/// <param name="dialog">The alert dialog to validate</param>
public
void
MyCustomAlertHandler(IDialog dialog)
{
string
txt = dialog.Window.AllChildren[dialog.Window.AllChildren.Count - 1].Caption;
Assert.AreEqual<
string
>(
"Hello! I am an alert box!"
, txt);
Log.WriteLine(txt);
Window okButton = WindowManager.FindWindowRecursively(dialog.Window.Handle,
"OK"
,
false
, 0);
Manager.Desktop.Mouse.Click(MouseClickType.LeftClick, okButton.Rectangle);
dialog.HandleCount++;
}
All the best,
Cody
the Telerik team