大佬教程收集整理的这篇文章主要介绍了稍后将变量重用为整数/文本,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我曾尝试让 cypress 保存文本以备后用,但我觉得无法将其作为变量重用
cy.get('.unrd').then(($span) => {
const filteredunread = $span.text()
cy.wrap(filteredunread).as('oldunreadmessage');
})
发送邮件、等待并返回收件箱等待回显回复的代码块
cy.get('.unrd').then(($span) => {
cy.get('@oldunreadmessage') //seen as object
const newunread = $span.text()
expect(newunread).to.eq(cy.get('@oldunreadmessage') +1)
})
这给了我以下错误:
expected '(27)' to equal '[object Object]1'
我曾尝试使用 .as()。但是,我似乎无法将旧对象正确解析为文本或整数常量。
第一部分很好,但由于 cy.wrap
,您需要在 should
上使用 then
或 cy.get('@oldunreadmessage')
cy.get('.unrd').then(($span) => {
const newunread = $span.text();
cy.get('@oldunreadmessage').should('have.text',newunread);
})
或
cy.get('.unrd').then(($span) => {
const newunread = $span.text();
cy.get('@oldunreadmessage').then((oldunread) => {
expect(newunread)...
}
})
以上是大佬教程为你收集整理的稍后将变量重用为整数/文本全部内容,希望文章能够帮你解决稍后将变量重用为整数/文本所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。