【发布时间】:2020-02-21 00:29:51
【问题描述】:
我正在尝试仅在电子邮件地址不是可选的情况下对其进行测试。我原以为这会起作用,但事实并非如此。
在我的 html 中,我有 <input type="hidden" id="Customer_AllowEmailToBeOptional" value="false" >
cy.get('#Customer_AllowEmailToBeOptional').should('have.value', 'false') // passes the test
cy.get('#Customer_AllowEmailToBeOptional').then(($allowEmail) => {
console.log('text=' + JSON.stringify( $allowEmail)); // text={"0":{},"length":1}
if ($allowEmail.text() === 'false') {
// test email is valid
}
})
我原以为当 .then() 执行时,我可以访问 .text() 值。我哪里错了?
【问题讨论】:
标签: cypress