如何使用赛普拉斯检查拨动开关是否已启用?

How to check with cypress that the toggle switch is enabled?

我想添加一个检查是否使用 cypress 启用了切换开关。

下面是html代码,

<div>
    <label for="automated">
    <label value="true" class="StyledSwitch-1234">
        <input type="checkbox" id="automated" checked>
        <i class="container"></i>
        <span class="label" data-enabled="on" data-disabled="off"></span>
    </label>
</div>

现在我如何检查带有 ID 为“automated”的输入子标签的值为“true”。

我可以像这样自动访问带有 id 的输入

cy.get('input[id="automated"]')

但我是否获取其父标签并检查其值属性是否为真。

有人可以帮我解决这个问题吗?谢谢。

已启用:

cy.get('#automated').should('be.checked')

对于未启用:

cy.get('#automated').should('not.be.checked')