I\'m trying to test the \"Remember Me\" functionality of a login form. I\'m able to type in the user name and password, click the checkbox, click submit, and quit() or close
If the "Remember Me" feature is implemented using persistent cookies (I doubt that there is any other way to implement it), then you can actually test the feature in a cross-browser compatible way by programmatically manipulating the cookies. Cookies with an expiration date (or Expiry in the Selenium API) are persistent cookies and are stored when the browser is closed and retrieved when the browser is re-opened. Non-persistent cookies are not stored when the browser is closed. With this information, we can simulate what should happen when the browser closes, by programmatically deleting all non-persistent cookies:
// Check the "Remember Me" checkbox and login here.
Set cookies = webDriver.manage().getCookies();
for (Cookie cookie : cookies) {
// Simulate a browser restart by removing all non-persistent cookies.
if (cookie.getExpiry() == null) {
webDriver.manage().deleteCookie(cookie);
}
}
// Reload the login page.
webDriver.get(currentLoginPageURL);
// Assert that some text like "You are logged in as..." appears on the page to
// indicate that you are still logged in.