gpt4 book ai didi

javascript - Testcafe headless 可见性检查

转载 作者:搜寻专家 更新时间:2023-10-30 21:06:24 25 4
gpt4 key购买 nike

在 headless 模式下运行时,测试是否应该进行可见性检查?当我在正常的 chrome 或 firefox 中运行测试时,它们都通过了,但在 headless 模式下,我不断收到此错误:

test('Assert navigation from Home to page x...', async t => {
await t
.expect(link.textContent).eql('page x')
.click(link)
.expect(getPageUrl()).contains('pagex')
});

Error: The element that matches the specified selector is not visible.

当我添加 expect([someSelector].visibile).ok() 时,我得到这个错误:

   AssertionError: expected false to be truthy

我觉得我为了在 headless 模式下运行它们的特定目的而编写这些测试的方法是不正确的。我不确定在 headless 模式下运行是否会影响测试结构的整体方法?

我正在编写许多可以集成到 Jenkins 中的端到端测试,以便它们在提交新代码时运行。

最佳答案

你想要 t.expect(selector.visible).ok()

可见性只是检查元素是否存在于 DOM 中,并且没有 visible: hiddendisplay: none 样式规则集

headless 运行不会影响这一点,因此可能存在其他问题。

关于javascript - Testcafe headless 可见性检查,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52617560/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com