testing - Testcafe:您要切换到的 iframe 的内容未加载
问题描述
Testcafe v 1.9.4 在本地运行测试时一切正常 Wneh 通过 GitLab 运行:
1) Content of the iframe to which you are switching did not load.
Browser: Chrome 86.0.4240.111 / Linux 0.0
119 |
120 |
121 | await t.expect(this.cke1.exists).ok({timeout:60000})
122 | await
t.expect(this.cke1.visible).ok({timeout:60000})
123 |
> 124 | await t.switchToIframe(this.cke1);
我添加: await t.eval(() => location.reload(true)); 但它没有帮助这个问题大约在一周前出现。之前也没事。代码很久没改了 可能是什么原因?
解决方案
此错误可能是由于加载 iframe 文档需要太多时间而导致的。我假设CI机器没有太多的CPU和内存资源,所以测试可能不稳定。我建议您增加 iframe 选择器超时时间:Wait Until an Is Loaded。此外,您可以尝试使用如何检查 iframe 是否已加载或是否有内容中描述的解决方法来实现 ClientFunction ?等待 iframe 内容加载。