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?
- AAdd the cookie before creating the WebDriver session
- BNavigate to a page on shop.example.test first, add the cookie in that current domain context, then navigate to the account page
- CStore the cookie in ChromeOptions after the browser has started
- DUse Actions.clickAndHold to activate the cookie jar
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
selenium-cookiesbrowser-statetest-isolationselenium