Selenium / Quiz

Cookie State Under Test Control

Manage login state and cleanup through Selenium 4 Java cookie APIs without confusing browser cookies with all client storage.

Difficulty
Medium
Format
Quiz
Points
150
Estimate
8 min

// MISSION BRIEF

Your Mission

The suite needs faster authenticated setup and reliable isolation between tests. Inspect cookie snapshots and domain context, then decide what WebDriver can restore, inspect, and remove safely.

// FIRST CONTACT

Battle teaser

A fresh browser executes: driver.manage().addCookie(new Cookie("session", "abc123")); driver.get("https://shop.example.test/account"); The first line fails with an invalid cookie domain error. What ordering is required?

  1. AAdd the cookie before creating the WebDriver session
  2. BNavigate to a page on shop.example.test first, add the cookie in that current domain context, then navigate to the account page
  3. CStore the cookie in ChromeOptions after the browser has started
  4. DUse Actions.clickAndHold to activate the cookie jar
Answers, scoring, hints, and the full battle stay sealed.

// SKILL TAGS

selenium-cookiesbrowser-statetest-isolationselenium