cypress超时重试:cy.its()错误,因为主题上的属性clientHeight不存在

问题描述 投票:0回答:1

以下:

cy.get( '@bar' ).
  its( 'clientHeight' ).
    should( 'eq', '300px' );

此CypressError失败:

Timed out retrying: cy.its() errored because the property: clientHeight does not exist on your subject.

cy.its() waited for the specified property clientHeight to exist, but it never did.

浏览器支持Element.clientHeight,因为我在代码中使用了它,并且正确使用了相同别名上的其他声明。

感谢您的任何建议!

cypress
1个回答
0
投票

Cypress命令cy.get()产生一个引用DOM元素或DOM元素集合的jquery对象。您可以在以下位置找到有关差异的很好的解释:jQuery object and DOM element

获得clientHeight属性的方法是使用get(index)方法从产生的jquery对象访问DOM元素:

get(index)
© www.soinside.com 2019 - 2024. All rights reserved.