开发者

Handling Inline JavaScript Dialogues with WatiN

开发者 https://www.devze.com 2023-03-07 14:18 出处:网络
The site that we\'re currently writing tests for has some JavaScript confirm and alert dialogues that happen after the page has refre开发者_如何学Pythonshed, and are written in inline JavaScript. For

The site that we're currently writing tests for has some JavaScript confirm and alert dialogues that happen after the page has refre开发者_如何学Pythonshed, and are written in inline JavaScript. For example:

<script>
if (confirm('Outcome has been saved. Click OK to create a followup appointment, or click Cancel to return to appointment outcome details.')) {
   pbFup.click();
}
</script>

Our test scripts don't seem to be able to handle this, and I can't figure out if we're doing something wrong, or if it's failing because WatiN can't handle the inline JavaScript. One of our tests looks like this:

var confirmDialogHandler = new ConfirmDialogHandler();
using (new UseDialogOnce(IEInstance.DialogWatcher, ConfirmDialogHandler))
{
    frame.Button(Find.ByName("cbnSave")).Click();
    // The page should reload here.
    confirmDialogHandler.WaitUntilExists();
    confirmDialogHandler.OKButton.Click();
}
IEInstance.WaitForComplete();


I used AlertDialogHandler() and it's working for me now.

0

精彩评论

暂无评论...
验证码 换一张
取 消