Skip to main content
← TesterRank/Topics

Cookies & Storage

Practice reading and writing cookies, localStorage, and sessionStorage.

Browser Storage

Cookie Operations

Set, read, and delete a browser cookie.

No cookie action yet

Hint: In Selenium: driver.manage().addCookie(), getCookieNamed(), deleteCookieNamed(). In Playwright: context.addCookies(), context.cookies().

localStorage Operations

Add, retrieve, and remove items from localStorage.

localStorage is empty (exercise items)

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.

sessionStorage is empty

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

This area reflects the current theme. The theme preference is stored in a cookie named "theme".

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.