Handle alert dialog with WatiN
Useful objects of WatiN are DialogHandlers.We can use one of them : AlertDialogHandler to handle a window.alert dialog.
However the WatiN Recoder still generate correct codes about such a scenario so far(But I always think WatiN Recoder is a very graet tool).
Let\'s look the completely correct codes as follows:
However the WatiN Recoder still generate correct codes about such a scenario so far(But I always think WatiN Recoder is a very graet tool).
Let\'s look the completely correct codes as follows:
1
WatiN.Core.IE ie = new IE();
2
ie.GoTo("http://localhost/approval");
3
AlertDialogHandler alertDialogHandler = new AlertDialogHandler();
4
ie.AddDialogHandler(alertDialogHandler);
5
ie.Button(Find.ById("BtnSubmit")).ClickNoWait();
6
alertDialogHandler.WaitUntilExists();
7
alertDialogHandler.OKButton.Click();
8
ie.WaitForComplete();
2
3
4
5
6
7
8