Recall & Review
beginner
What is a cookie in web testing?
A cookie is a small piece of data stored by the browser to remember information about the user or session. In testing, cookies help verify session management and user preferences.
Click to reveal answer
beginner
How do you add a cookie using Selenium WebDriver in Java?
Use the method
driver.manage().addCookie(new Cookie("name", "value")); to add a cookie to the current browser session.Click to reveal answer
beginner
What is the purpose of
driver.manage().deleteAllCookies()?It deletes all cookies stored in the browser for the current domain, useful to reset session state before tests.
Click to reveal answer
intermediate
How can you retrieve a specific cookie by name in Selenium Java?
Use
Cookie cookie = driver.manage().getCookieNamed("cookieName"); to get the cookie object by its name.Click to reveal answer
intermediate
Why is cookie management important in automated web testing?
Managing cookies helps simulate real user sessions, test login persistence, and control test environment by clearing or setting cookies as needed.
Click to reveal answer
Which Selenium method is used to add a cookie in Java?
✗ Incorrect
The correct method to add a cookie is driver.manage().addCookie() with a Cookie object.
What does
driver.manage().deleteAllCookies() do?✗ Incorrect
It deletes all cookies stored for the current domain in the browser session.
How do you get a cookie named "sessionId" in Selenium Java?
✗ Incorrect
Use driver.manage().getCookieNamed("sessionId") to retrieve a cookie by name.
Why might you clear cookies before running a test?
✗ Incorrect
Clearing cookies simulates a fresh user session without previous data.
Which of these is NOT a valid cookie attribute in Selenium's Cookie class?
✗ Incorrect
Cookie attributes include name, value, domain, path, expiry, but not color.
Explain how to add, retrieve, and delete cookies using Selenium WebDriver in Java.
Think about the manage() interface in Selenium WebDriver.
You got /3 concepts.
Why is managing cookies important in automated web testing? Give examples.
Consider what cookies store and how tests depend on session data.
You got /4 concepts.