【问题标题】:Is there a way to wait for a window to close, with TestCafe有没有办法用TestCafe等待窗口关闭
【发布时间】:2021-03-09 22:16:01
【问题描述】:

我有一组自动化测试,它们打开一个子窗口+单击一个按钮关闭子窗口,然后导致页面导航。断言 URL 结果为Failed to restore connection to window within the allocated timeout.

// In child window
await t.typeText(<field>, 'text').click(<submitButton>);

// Main window
await t.expect(getCurrentUrl()).contains('thank_you')

我这里的假设是TestCafe仍然相信它在子窗口中,无需等待窗口关闭,以及后续的页面导航。

我可以添加一些验证,以确保我们回到主窗口...但我想知道是否有针对此问题的内置解决方案? (我在文档中看不到任何内容)。

【问题讨论】:

    标签: javascript testing automated-tests e2e-testing testcafe


    【解决方案1】:

    关闭子窗口后,执行以下命令:

    await t.switchToMainWindow();
    

    【讨论】:

    • 遗憾的是这并没有什么不同,我也尝试了await t.switchToParentWindow();,但出现了同样的错误。我用 TestCafe 提出了一个错误,看看它是否可以被复制。 github.com/DevExpress/testcafe/issues/6038
    • 我研究了你的案例,结果发现它比我想象的要复杂。这种行为看起来像一个错误。感谢您的报告。
    猜你喜欢
    • 2022-01-13
    • 1970-01-01
    • 2020-10-22
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 2020-03-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多