【问题标题】:Handling Inline JavaScript Dialogues with WatiN使用 WatiN 处理内联 JavaScript 对话
【发布时间】: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


【解决方案1】:

我使用了 AlertDialogHandler(),它现在对我有用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-15
    • 1970-01-01
    • 1970-01-01
    • 2011-11-30
    • 1970-01-01
    • 2011-09-06
    • 2017-07-14
    相关资源
    最近更新 更多