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();
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();
浙公网安备 33010602011771号