最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Cypress save cookie value - Stack Overflow

programmeradmin1浏览0评论

I want to save a cookie value using Cypress, but unfortunately I always get undefined in the log console using this code

let cookieValue;
cy.getCookie('SOME_COOKIE')
    .should('have.property', 'value')
    .then((cookie) => {
        cookieValue = cookie.value;
    })
cy.log(cookieValue);

When I try this

let cookieValue;
cy.getCookie('SOME_COOKIE')
    .should('have.property', 'value', 'Dummy value')
    .then((cookie) => {
        cookieValue = cookie.value;
    })
cy.log(cookieValue);

I can see the actual value I want in the error message.

I want to save a cookie value using Cypress, but unfortunately I always get undefined in the log console using this code

let cookieValue;
cy.getCookie('SOME_COOKIE')
    .should('have.property', 'value')
    .then((cookie) => {
        cookieValue = cookie.value;
    })
cy.log(cookieValue);

When I try this

let cookieValue;
cy.getCookie('SOME_COOKIE')
    .should('have.property', 'value', 'Dummy value')
    .then((cookie) => {
        cookieValue = cookie.value;
    })
cy.log(cookieValue);

I can see the actual value I want in the error message.

Share Improve this question asked Mar 14, 2019 at 17:10 ounisounis 431 silver badge4 bronze badges 2
  • If it solved your problem, please accept the answer, it could be really helpful for other users landing here with the same issue
发布评论

评论列表(0)

  1. 暂无评论