问题
I want to use WatiN to verify the error message in a JavaScript alert box. Is this possible? Thanks.
回答1:
see Trev's Blog and here as well.
using(IE ie = new IE("http://hostname/pagename.htm"))
{
AlertDialogHandler alertDialogHandler = new AlertDialogHandler();
using (new UseDialogOnce(ie.DialogWatcher, alertDialogHandler ))
{
/*************************************
* -- alert -- *
* *
* must use the "NoWait" to allow *
* the code to goto the next line *
* *
*************************************/
alertDialogHandler.WaitUntilExists();
alertDialogHandler.OKButton.Click();
ie.WaitForComplete();
}
}
来源:https://stackoverflow.com/questions/458177/can-i-read-javascript-alert-box-with-watin