Cookies & Storage
Practice reading and writing cookies, localStorage, and sessionStorage.
Browser Storage
Cookie Operations
Set, read, and delete a browser cookie.
Hint: In Selenium: driver.manage().addCookie(), getCookieNamed(), deleteCookieNamed(). In Playwright: context.addCookies(), context.cookies().
localStorage Operations
Add, retrieve, and remove items from localStorage.
0 items in localStorage
Hint:In Selenium, use JavaScriptExecutor: executeScript('return localStorage.getItem(key)'). In Playwright: page.evaluate(() => localStorage.getItem(key)).
sessionStorage Operations
Work with sessionStorage -- data that clears when the tab is closed.
Note: sessionStorage data is scoped to the current tab and will be cleared when the tab is closed.
0 items in sessionStorage
Hint:sessionStorage is per-tab. Opening a new tab won't have the same data. Test this by verifying data doesn't persist across page.goto() in a new context.
Practical Usage
Cookie-Based Theme
Toggle between light and dark themes. The preference is saved in a cookie.
Current: light
Hint: Cookies persist across sessions. Set a cookie, reload the page, and verify the theme is remembered. Test both themes.
Remember Form Data
Fill in the form and check "Remember my details" to save data to localStorage.
Details will not be saved
Hint: Verify pre-filled values after page reload. Use driver.navigate().refresh() then check input values. Clear localStorage to test empty state.