当我展开包含复选框列表的复选框父级时,想要循环所有复选框以确保只选择其中的几个:
//expand parent
// select checkbox1
cy.get('[aria-label="checkbox1"]').check({ force: true });
// select checkbox 5
cy.get('[aria-label="checkbox5"]').check({ force: true });
//close then expand again
Run Code Online (Sandbox Code Playgroud)
问题:如何轻松循环父级下的所有复选框以仅检查 checkbox1 和 5(按名称)是否被选中?
我希望在这种情况下进行条件测试,表可能存在或不存在:
if (cy.get(#grid).should('not.exist')) {
//do something
} else {
//so something else
}
Run Code Online (Sandbox Code Playgroud)
但似乎不建议进行条件测试?有什么建议吗?