此按钮有两种状态:禁用时为“chevron_right”。启用时为“expand_more”。
其默认状态为“chevron_right”
以下代码将在第一次单击按钮时单击。但是一旦启用它,就会出现错误,提示找不到“chevron_right”。有人知道我做错了什么吗?
cy.get('#TreeView mat-nested-tree-node').find('button').first().then(button => {
if (cy.wrap(button).contains('chevron_right')) {
cy.wrap(button).click()
} else{
cy.log("Do nothing")
}
})
页面上有多个按钮具有这两种状态,因此我无法只搜索其中的一个实例。