我可以使用 WatiN 读取 JavaScript 警报框吗? [英] Can I read JavaScript alert box with WatiN?

查看:26
本文介绍了我可以使用 WatiN 读取 JavaScript 警报框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to use WatiN to verify the error message in a JavaScript alert box. Is this possible? Thanks.

推荐答案

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

这篇关于我可以使用 WatiN 读取 JavaScript 警报框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆