从if语句中传递可变值
如果条件还可以,我只需要通过按钮变量传递true即可。然后,如果按钮变量值为真,则需要传递测试用例。有人可以帮我解决这个问题吗?这就是我到目前为止所得到的。
cy.get('@checkSkipButton').then(checkSkipButton => {
if (checkSkipButton) {
cy.log("NOT CLICKABLE")
cy.then(button = true)
//cy.log(button)
//return button;
//cy.log(button)
//return button
}else{
cy.log("CLICKABLE")
button = False
//return this
}
} )
cy.log("value is"+button)
button.should(have,value=true)
}
I just need to pass true for the button variable if the if condition is ok. Then i need to pass the test case if the button variable value is true. Can someone help me to fix this. This is what i have got so far.
cy.get('@checkSkipButton').then(checkSkipButton => {
if (checkSkipButton) {
cy.log("NOT CLICKABLE")
cy.then(button = true)
//cy.log(button)
//return button;
//cy.log(button)
//return button
}else{
cy.log("CLICKABLE")
button = False
//return this
}
} )
cy.log("value is"+button)
button.should(have,value=true)
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
该代码接近工作,但是
false
而不是false
,然后返回按钮
让您链接.shold() /代码>测试。
The code is close to working, but
false
instead ofFalse
and return thebutton
to let you chain the.should()
test.我认为这是相同的逻辑
I think this is the same logic
如果要全球使用
按钮
,则必须使用then()
来等待其值If you want to use
button
globally, you must wait for it's value to be set by using.then()
您非常接近,上面的情况会很好地进行一些修改。
You were very close, the above will work fine with some minor changes.