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?