【发布时间】:2011-05-23 09:57:13
【问题描述】:
我们目前正在为其编写测试的网站有一些 JavaScript 确认和警告对话框,这些对话框会在页面刷新后发生,并且是用内联 JavaScript 编写的。例如:
<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>
我们的测试脚本似乎无法处理这个问题,我不知道是我们做错了什么,还是因为 WatiN 无法处理内联 JavaScript 而导致失败。我们的一项测试如下所示:
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();
【问题讨论】:
-
你试过
frame.Button(Find.ByName("cbnSave")).ClickNoWait(); -
是的,我们确实尝试过,但结果是一样的。
标签: c# automated-tests integration-testing watin