我想使用Cypress保存cookie值,但不幸的是,使用此代码时,在日志控制台中始终获取undefined结果。
let cookieValue;
cy.getCookie('SOME_COOKIE')
.should('have.property', 'value')
.then((cookie) => {
cookieValue = cookie.value;
})
cy.log(cookieValue);
当我尝试这样做时
let cookieValue;
cy.getCookie('SOME_COOKIE')
.should('have.property', 'value', 'Dummy value')
.then((cookie) => {
cookieValue = cookie.value;
})
cy.log(cookieValue);
我可以在错误消息中看到实际想要的值。