public void shouldRetainCookieInfo() {
server.setHttpHandler("GET", EMPTY_CALLBACK);
goToPage();
// Added cookie (in a sub-path - allowed)
Cookie addedCookie =
new Cookie.Builder("fish", "cod")
.expiresOn(new Date(System.currentTimeMillis() + 100 * 1000)) //< now + 100sec
.path("/404")
.domain("localhost")
.build();
driver.manage().addCookie(addedCookie);
// Search cookie on the root-path and fail to find it
Cookie retrieved = driver.manage().getCookieNamed("fish");
assertNull(retrieved);
// Go to the "/404" sub-path (to find the cookie)
goToPage("404");
retrieved = driver.manage().getCookieNamed("fish");
assertNotNull(retrieved);
// Check that it all matches
assertEquals(addedCookie.getName(), retrieved.getName());
assertEquals(addedCookie.getValue(), retrieved.getValue());
assertEquals(addedCookie.getExpiry(), retrieved.getExpiry());
assertEquals(addedCookie.isSecure(), retrieved.isSecure());
assertEquals(addedCookie.getPath(), retrieved.getPath());
assertTrue(retrieved.getDomain().contains(addedCookie.getDomain()));
}