Clear sessionStorage in between tests
See original GitHub issueCurrently we clear cookies
and localStorage
but somehow we missed automatically clearing sessionStorage
as well.
This needs to be added, and we likely need to add a new cy.clearSessionStorage
API command.
Thanks to @abadstubner for finding this one.
Currently as a workaround you can manually clear sessionStorage
like this:
cy.window().then((win) => {
win.sessionStorage.clear()
})
Issue Analytics
- State:
- Created 7 years ago
- Reactions:124
- Comments:29 (10 by maintainers)
Top Results From Across the Web
session - Cypress Documentation
When running Cypress in "open" mode, you can explicitly clear all spec and global sessions and re-run the spec file by clicking the...
Read more >Why do I need to explicitly clear sessionStorage when using ...
The controller stores the current page in $sessionStorage.pagination. If I don't explicitly clear the session storage between tests, ...
Read more >How to clear session storage data with specified session ...
We can get specified session storage using the getItem() method. We can clear the session storage by using the clear() method.
Read more >How to preserve localStorage between Cypress tests
Cypress by default clears localStorage between tests, which may be a problem when you are trying to test features related to it.
Read more >How to clear localStorage using selenium and webdriver
I have confirmed by testing both the Firefox and Chrome drivers, that upon instantiating the driver, the browser's localStorage is empty. This is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
clearing sessionStorage are just synchronous methods you call on the
window
.Read https://docs.cypress.io/api/events/catalog-of-events.html as well.
When will
cy.clearSessionStorage
be implemented?None of the workarounds have worked here. I am even clearing session store beforeEach and onBeforeLoad. The result is tests randomly passing, definitely a race condition.
One time the entire suite passes. The next time one test fails. The next time three fails. The next time two different tests fail…