如何测试图像是否已在testcafe中充满负载

发布于 2025-02-03 22:11:37 字数 60 浏览 3 评论 0原文

我需要创建一个助手来验证图像是否已在testcafe中充分加载,我对Testcafe非常新鲜。请帮助 谢谢

I need to create a helper to verify whether the image is fully loaded in testcafe, I'm very new to testcafe.Please help
Thanks

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

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

发布评论

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

评论(1

别想她 2025-02-10 22:11:37

检查完整://developer.mozilla.org/en-us/docs/web/api/htmlimageelement/naturalalwidth“ rel =“ nofollow noreferrer”> naturalwidth> naturalWidth 元素的属性。您可以使用 href =“ https://testcafe.io/documentation/402759/reference/test-api/selector/addcustomdomdomproperties#header” rel =“ nofollow noreferrer”>“ nofollow noreferrer”> selector selector自定义域。例如:

import { Selector } from 'testcafe';

fixture`Check images`
    .page`google.com`;

test('Test', async t => {
    const image = Selector('img[alt=Google]').addCustomDOMProperties({
        complete:     node => node.complete,
        naturalWidth: node => node.naturalWidth
    });

    await t
        .expect(image.complete).ok()
        .expect(image.naturalWidth).eql(272);
});

Check the complete and naturalWidth properties of the element. You can access them with the ClientFunction or Selector custom DOM properties. For example:

import { Selector } from 'testcafe';

fixture`Check images`
    .page`google.com`;

test('Test', async t => {
    const image = Selector('img[alt=Google]').addCustomDOMProperties({
        complete:     node => node.complete,
        naturalWidth: node => node.naturalWidth
    });

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