testcafe 如何判断 iframe 已加载?

发布于 2025-01-15 06:37:17 字数 813 浏览 0 评论 0原文

我目前使用的是最新的软件包 1.18.4,并且在测试执行期间切换到 iframe 时遇到问题。

每次调用 t.switchToIframe() 时,都会显示以下错误:

Content of the iframe in which the test is currently operating did not load.

即使我可以清楚地看到 iframe 已加载,甚至在出于测试目的登陆页面时放置了 60 秒的等待时间,也会发生这种情况。

下面的粗略代码应该可以运行并重现问题:

import { Selector, t } from "testcafe";

fixture(`Quick Test`);

test
 .page(`https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295`)(
  `Quick Test`,
  async () => {
      await t
       .click(`.submit-outer`)
       .expect(Selector(`.car-summary-box`).visible)
       .ok()
       .expect(Selector(`.cw-finance-plugin.plugin-loaded`).visible)
       .ok()
       .switchToIframe(`.cw-finance-plugin.plugin-loaded`)
       .click(`.cw-checkmark`)
       .debug();
  });

I'm currently on the latest package 1.18.4 and having issues switching to an iframe during test execution.

Each time t.switchToIframe() is called, the following error is displayed:

Content of the iframe in which the test is currently operating did not load.

This happens even though i can clearly see the iframe has loaded, even placing a length wait of 60 seconds when landing on the page for testing purposes.

This rough code below should be runnable and reproduce the problem:

import { Selector, t } from "testcafe";

fixture(`Quick Test`);

test
 .page(`https://www.terrific.ie/dealer/bradys-of-castleknock/finance/45784/13295`)(
  `Quick Test`,
  async () => {
      await t
       .click(`.submit-outer`)
       .expect(Selector(`.car-summary-box`).visible)
       .ok()
       .expect(Selector(`.cw-finance-plugin.plugin-loaded`).visible)
       .ok()
       .switchToIframe(`.cw-finance-plugin.plugin-loaded`)
       .click(`.cw-checkmark`)
       .debug();
  });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冷情妓 2025-01-22 06:37:17

一般来说,切换到iframe有两个步骤。第一步是获取带有 iframe 的选择器,但如果选择器不存在,您将收到另一个错误。下一步是使用本机 getter 获取 contentWindow。该错误可能发生在这一步,但我无法用您的 iframe 示例重现这种情况。您能否分享一个完整的测试示例来说明此错误?

另外,您将 iframe 的内容放在标签之间,但它不会像这样工作。您需要在 iframe 的 src 属性中设置文档的路径。

In general, there are two steps to switch to iframe. The first step is getting a selector with an iframe, but if the selector doesn't exist, you will get another error. The next step is getting contentWindow with a native getter. The error probably occurs on this step, but I can't reproduce this case with your iframe example. Could you share a full test example that illustrates this error?

Also, you put the content of the iframe between the tags, but it doesn't work like this. You need to set the path to the document in the src attribute of the iframe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文