-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
localStorage being set on wrong domain #3177
Comments
I was able to do some debugging with Currently. i do not have a good solution or know if this is only happening in |
Hey @egucciar, can you provide the full test code? Include where you call the |
I can do that but there's still multiple repositories invovled in our ecosystem including docker and private npm packages. I would still need to spend an hour or so throwing it together so you won't need any our our permissions to run. I'll be able to get to this in 1-2weeks. Thank you! |
Unfortunately we have to close this issue as there is not enough information to reproduce the problem. Please comment in this issue with a reproducible example and we will reopen the issue. 🙏 |
I am running into this issue as well and created a very simple test to demonstrate what I am seeing. It does not seem possible to set a value into local storage for a site on a domain that is different from the baseUrl cypress started with until after With baseUrl set to anything other than github.com in cypress.json (example: it('setLocalStorage', () => {
Cypress.config("baseUrl", "https://github.com");
cy.log(Cypress.config().baseUrl);
//cy.visit(''); // uncomment this to setItem on https://github.com
window.localStorage.setItem('session_item', "Where will this go?");
}); Without calling |
Same issue here as in example above. Cypress doesn't target the right localStorage after setting baseUrl - it needs a visit. Can this be reopened? Thanks! |
@Sean-WadeAndWendy Yeah, there wouldn't be a
Also, if you want to set We could maybe make this behavior clearer since it seems to have confused some people. it('setLocalStorage', () => {
// this is the Cypress window, at http://localhost:60354/__cypress/iframes/integration/spec.js
window
cy.visit('https://www.example.com').then((win) => {
// this is the application under test window, https://www.example.com
win
})
}); If you want to set cy.visit('https://www.example.com', {
onBeforeLoad: (win) => {
// this is the application under test window, https://www.example.com
win.localStorage.setItem('session_item', "abc123");
}
}) Edited for clarity |
Current behavior:
We use the following code to set
baseUrl
:Which demonstrates that the
baseUrl
of Cypress is set as follows:Shortly after, we set some stuff in the localStorage.
we use something like this:
This then is updating the wrong Domain/Origin.
Notice that the
baseUrl
is set to beapp.moving.dev.updater.com
, whereas the url being chosen here isapp.dev.updater.com
.There's no telling why it is setting on this other Domain as of now. This is failing my test and blocking my progress forward. I cannot perform a
visit
before the first setting either, as this will mess up my tests.I am simply doing a refactor from one domain to another domain as of now, and for some reason, it is still "hanging on" to this previous domain. And I do not know why.
Desired behavior:
I want the
localStorage
setting to occur on thebaseUrl
I have set.Steps to reproduce: (app code and test code)
I really do not know how i can just hand over my private code for you to reproduce. But please see if any advice could be given regardless.
If a reproducible example is ultimately required, It is not feasible given my priorities and timelines to create one this instant. It will require extensive work to make a reproducer as this will require debugging, sourcing the issue, and docker containers to be able to spin up a DNS for actually reproducing.
Versions
MacOS, 3.1.4 Cypress
The text was updated successfully, but these errors were encountered: