如何在赛普拉斯测试中设置cookie? [英] How to set cookies within Cypress testing?

查看:126
本文介绍了如何在赛普拉斯测试中设置cookie?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此示例取自赛普拉斯文档无法正常工作:

this example taken from the Cypress documentation won't work properly:

cy.getCookies().should('be.empty');
cy.setCookie('session_id', '189jd09sufh33aaiidhf99d09');
cy.getCookie('session_id').should('have.property', 'value', '189jd09sufh33aaiidhf99d09');

每次我尝试设置setCookie()时,它似乎都没有问题地设置了它,但总是在返回该值时我叫getCookies():

Every time I try to setCookie(), it appears to set it without issue but always returns this when I call getCookies():

$Chainer {chainerId: "chainer18", firstCall: false}
chainerId: "chainer18"
firstCall: false
__proto__: Object

我有东西吗?我在这里丢失了吗?

Is there something I'm missing here?

推荐答案

类似这与 https://github.com/cypress-io/cypress/issues/1321 ,并且已在赛普拉斯的3.1.2版中进行了修补。万事大吉了。

Looks like this was related to https://github.com/cypress-io/cypress/issues/1321 and has been patched in v 3.1.2 of Cypress. All is right with the world again.

这篇关于如何在赛普拉斯测试中设置cookie?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆