Can I read JavaScript alert box with WatiN?

扶醉桌前 提交于 2019-12-20 19:08:06

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!