0

Watin 无法使用 IE 9 捕获浏览器弹出窗口。相反,如果抛出此类弹出窗口,我想跳过它并继续执行程序的其余部分。有可能以这种方式跳过吗?

弹出窗口是 JavaScript 弹出窗口。

4

1 回答 1

0

您提到弹出窗口是 JS 弹出窗口,您不能忽略它们并继续,因为浏览器主窗口变亮并且控件显示弹出消息。

你可以试试

var browser = new IE();
var url = "someurl";
browser.GoTo(url);

//经过一些导航后会弹出一个aapers

//当popupappears控件不自动返回代码并在IE忙时给出超时异常。

所以我们需要在这里使用

somebtton.ClickNoWait() //In case of Button Click

browser.GoToNoWait()   // In case of pop up appearing just after navigation.


            //Finds the alert dialog if it appears
        AlertDialogHandler AlertDialog = new AlertDialogHandler();
        try
        {
            //Code for checking if the case number is invalid and a dialog box appears.
            Settings.AutoStartDialogWatcher = true;
            Settings.AutoCloseDialogs = true;

            browser.AddDialogHandler(AlertDialog);

            AlertDialog.WaitUntilExists();

            //If alert dialog is found then close the dialog and log error
            if (AlertDialog.Exists())
            {

                //Click OK button of the dialog so that dialog gets closed
                AlertDialog.OKButton.Click();
                browser.WaitForComplete();
                browser.RemoveDialogHandler(AlertDialog);                    

            }
        }
        catch
        {
                //Removes the dialog handler if the Dialog dosen't appear within 30 secs.
                browser.RemoveDialogHandler(AlertDialog);               
        }

尝试一下,如果您仍然遇到问题,请显示一些代码,例如您正在做的事情。

于 2013-06-24T11:59:21.690 回答