问题 我可以使用WatiN阅读JavaScript警告框吗?


我想使用WatiN来验证JavaScript警告框中的错误消息。这可能吗?谢谢。


8896
2018-01-19 16:21


起源



答案:


看到 Trev的博客 和 这里 同样。

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();
    }
}

13
2018-01-19 16:39



我道歉 - 我第一次没有仔细阅读这篇文章并且认为它没有回答我的问题,但确实如此!谢谢! - Leslie
NP - 很乐意提供帮助! - Dror


答案:


看到 Trev的博客 和 这里 同样。

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();
    }
}

13
2018-01-19 16:39



我道歉 - 我第一次没有仔细阅读这篇文章并且认为它没有回答我的问题,但确实如此!谢谢! - Leslie
NP - 很乐意提供帮助! - Dror