Can I read JavaScript alert box with WatiN?

前端 未结 1 1399
一个人的身影
一个人的身影 2021-02-08 09:44

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

相关标签:
1条回答
  • 2021-02-08 10:07

    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();
        }
    }
    
    0 讨论(0)
提交回复
热议问题