元素不可见,因为它具有 CSS 属性:'position: fixed'并且它被另一个元素覆盖



有人可以帮助我解决这个赛普拉斯错误吗?

Cypress Error: Timed out retrying: expected '<div.sub-categories-list>' to be '0 visible'
This element '<div.sub-categories-list>' is not visible because it has CSS property: 'position: fixed' and its being covered by another element:
undefined

您断言的元素在视口中不可见,可能必须滚动到才能可见。

Cypress 在测试运行期间不会自动滚动到元素,但您可以使用scrollIntoView(),因此请像这样编写您的断言:

cy.get('#yourElement')
.scrollIntoView()
.should('be.visible')

尝试更改覆盖所需元素的元素的CSS属性/类。

cy.get("#coveringElement").invoke('addclass','hidden');
cy.get('#yourDesiredElement');

将隐藏类添加到所有覆盖元素的类中。

最新更新