断言特定的html元素是Cypress中的按钮或选项卡



我浏览了Cypress中的文档,找不到检查HTML元素是否是选项卡的方法。我可以编写一个测试来断言文本、css等,但我想断言特定元素是选项卡。

我看到的是这样的东西:

cy.get("#enter").should("be", "tab"). 

您可以检查属性值对,如:

cy.get('#enter')
.should('have.attr', 'role', 'tab')

cy.get('#enter')
.should('have.attr', 'tabIndex', '1')

你也可以检查属性的存在:

cy.get('#enter')
.should("have.attr", "tabIndex")

最新更新