Low*_*wry 4 pdf testing automation e2e-testing testcafe
我正在测试的 Web 应用程序的一部分是单击一个按钮,这通常会在新选项卡中打开一个 PDF。这使用户能够在应用程序中继续前进。PDF 可以忽略。
目前,我的策略是单击按钮,然后使用 ClientFunction 导航回去。TestCafe在点击按钮时成功打开PDF,但是在同一个选项卡中打开,然后测试卡住了。向后导航会更改 URL,但仍会显示 PDF。
const goBack = ClientFunction(() => window.history.back())
await this.t.click(this.button)
await this.t.wait(10000)
await goBack()
Run Code Online (Sandbox Code Playgroud)
TestCafe 目前是否能够绕过这个问题,因为我实际上不需要对 PDF 做任何事情?
TestCafe 允许测试 html 页面,但不能测试 PDF 文件。因此,您可以将生成的 PDF 文件链接作为字符串检查,而无需实际遵循此链接。例如:
const overrideWindowOpen = ClientFunction(() => {
window.open = function (url) {
window.__lastWindowOpenUrl = url;
};
});
const getResultUrl = ClientFunction(() => window.__lastWindowOpenUrl);
await overrideWindowOpen();
await t
.click(this.button)
.expect(getResultUrl()).eql('http://example.com/path/to/PDF/93023813-0984-1');
Run Code Online (Sandbox Code Playgroud)
另请参阅:多浏览器窗口
| 归档时间: |
|
| 查看次数: |
1751 次 |
| 最近记录: |