Test Overview
This test checks if a web page correctly saves and retrieves data from the browser's local storage. It verifies that the stored value matches the expected value after setting it.
This test checks if a web page correctly saves and retrieves data from the browser's local storage. It verifies that the stored value matches the expected value after setting it.
describe('Local Storage Management Test', () => { it('should save and retrieve data from local storage', () => { cy.visit('https://example.cypress.io/commands/local-storage') cy.window().then((win) => { win.localStorage.setItem('myKey', 'myValue') }) cy.window().its('localStorage').invoke('getItem', 'myKey').should('equal', 'myValue') }) })
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Test starts | Test runner initialized, no browser opened yet | - | PASS |
| 2 | Browser opens and navigates to 'https://example.cypress.io/commands/local-storage' | Page loads with local storage commands example | - | PASS |
| 3 | Access browser window object and set localStorage item 'myKey' to 'myValue' | Local storage now contains key 'myKey' with value 'myValue' | - | PASS |
| 4 | Retrieve localStorage item 'myKey' and assert it equals 'myValue' | Local storage item 'myKey' is 'myValue' | Assert localStorage.getItem('myKey') === 'myValue' | PASS |