-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set cookie domain prefixed with a dot #1896
Comments
A couple of additional observations:
|
This is still an issue in Cypress 3.4.0. Reproducible test it('test 1', () => {
cy.visit('https://example.cypress.io')
cy.setCookie('myCookie', 'true', { domain: 'example.cypress.io' })
cy.getCookie('myCookie').should('have.property', 'domain', 'example.cypress.io')
}) I also narrowed down that this is an issue with the |
After further investigation - this is exactly how cookies work and are implemented within user agents. If you run this within the console - a document.cookie = "test=Hello;domain=example.cypress.io" Then go to the Cypress is simply passing along the domain information to the Notably, as part of the cookies spec, leading |
same here, how do you resolved this? |
I don't see anything |
Hi @jennifer-shehane! Although this is indeed native browsers behavior there IS a possibility to set dot-less cookie by not specifying domain at all: document.cookie = "test=Hello" And this is what we can meet in real applications. By using First cookie was set by PHP itself while second one by Cypress. One of those cookies is definitely outdated and wrong and you never know which one will be used by application. Would it be possible to add some extra option to cy.setCookie('test', 'value', {domain: 'example.com', domainExact: true})
cy.setCookie('test', 'value', {domain: 'api.example.com', domainExact: true})
cy.setCookie('test', 'value', {domain: 'static.example.com', domainExact: true}) And last but not least. I noticed that if my baseUrl is e.g. "docs.cypress.io" and I'm trying to |
Any updates on this issue? Having my tests fail in CI due to this prefixed |
Encountered this behavior as well. |
@xumepadismal I totally agree with what you said above. However, since this is a closed issue, I don't know if Cypress team will see this and act on it. Could you just open a new issue for this to grab their attention? I think the main point in this issue is that OR cc @jennifer-shehane and see if she can re-evaluate the issue |
@Songyu-Wang There is already an open issue #16856 to track this |
Ah thank you @xumepadismal |
Current behavior:
The problem I am having is that the website I am testing is hosted on www.something.com. The website is using cookies to avoid showing a popup multiple times. The cookie the website adds has a domain "www.something.com". I want to set this cookie when I start my test run so I don't get the popup.
When I use setCookie and pass it a domain "www.something.com", it actually adds a dot in the domain (.www.something.com). This causes the website to ignore this cookie and adds a duplicate cookie, without the dot before the domain.
Can I somehow force the setCookie to not alter my domain value?
Desired behavior:
The cookie domain to not be prefixed with a dot.
Steps to reproduce:
the assertion fails with ".www.something.com"
Versions
3.0.1
Windows 10
Chrome
The text was updated successfully, but these errors were encountered: