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:
1WatiN.Core.IE ie = new IE();
2ie.GoTo("http://localhost/approval");
3AlertDialogHandler alertDialogHandler = new AlertDialogHandler();
4ie.AddDialogHandler(alertDialogHandler);
5ie.Button(Find.ById("BtnSubmit")).ClickNoWait();
6alertDialogHandler.WaitUntilExists();
7alertDialogHandler.OKButton.Click();
8ie.WaitForComplete();

posted on 2007-05-22 22:38  WebQ  阅读(1427)  评论(7)    收藏  举报

导航