【问题标题】:Can I read JavaScript alert box with WatiN?我可以用 WatiN 读取 JavaScript 警告框吗?
【发布时间】:2009-01-19 16:21:14
【问题描述】:

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

【问题讨论】:

    标签: watin


    【解决方案1】:

    参见Trev's Bloghere

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

    【讨论】:

    • 我很抱歉——我第一次没有仔细阅读这篇文章并且认为它没有回答我的问题,但它确实回答了我的问题!谢谢!
    猜你喜欢
    • 1970-01-01
    • 2010-11-17
    • 2020-07-31
    • 1970-01-01
    • 1970-01-01
    • 2020-09-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多