Selenium WebDriver 4

Read a cookie value

Medium70 pts~25 min
  • Cookies
  • Browser state
Practice app · Document Vault

File upload and download, cookies, localStorage, sessionStorage and JavaScript execution.

Test URL
/lab/selenium-read-a-cookie-value

Your starter code already declares TEST_URL — never hardcode a host.

Objective

Let the app set a session cookie and read it back through the WebDriver cookie API.

Your task

  1. 1Click #set-cookie.
  2. 2Read the cookie named session_id with getCookieNamed / get_cookie / GetCookieNamed.
  3. 3Assert its value is “abc123”.
  4. 4Assert #cookie-value contains “session_id=abc123” so the UI and the driver agree.

Acceptance criteria

  • The cookie is read with the driver's cookie API
  • #cookie-value shows session_id=abc123
  • At least 2 assertions pass

Selenium WebDriver 4 · Selenium · Files, windows & storage