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.
精彩评论