如何根据元素的值在柏树中编写if-else条件?
根据if-condition的元素的价值变化,如何运行此功能?
assertSwitch(){
cy.get('[data-test="form-switch"]').invoke('attr','value').then(($switchOnOff) =>{
if($switchOnOff == true){
cy.isContain('.item-undefined-switch[data-test="item-undefined-email"]', 'true')
}else{
cy.isContain('.item-undefined-switch[data-test="item-undefined-email"]', 'false')
}
})
}
How can I run this function, according to the value change of element with if-condition?
assertSwitch(){
cy.get('[data-test="form-switch"]').invoke('attr','value').then(($switchOnOff) =>{
if($switchOnOff == true){
cy.isContain('.item-undefined-switch[data-test="item-undefined-email"]', 'true')
}else{
cy.isContain('.item-undefined-switch[data-test="item-undefined-email"]', 'false')
}
})
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是两个开关都具有相同的
数据测试
,因此柏树开始变得混乱或所有交换机
The problem is both switches have the same
data-test
, so Cypress starts to get confusedOr all switches
您可以做这样的事情:
You can do something like this: