Skip to content

Instantly share code, notes, and snippets.

@illicitonion
Created July 11, 2011 13:35
Show Gist options
  • Save illicitonion/1075850 to your computer and use it in GitHub Desktop.
Save illicitonion/1075850 to your computer and use it in GitHub Desktop.
public void testShouldBeAbleToIncludeLeadingPeriodInDomainName() throws Exception {
String name = gotoValidDomainAndClearCookies();
if (name == null || name.matches("\\d{1,3}(?:\\.\\d{1,3}){3}")) {
System.out.println("Skipping test: unable to find domain name to use");
return;
}
driver.manage().deleteAllCookies();
assertNull("Looks like delete all cookies doesn't", driver.manage().getCookieNamed("name"));
// Replace the first part of the name with a period
String shorter = name.replaceFirst(".*?\\.", "");
Cookie cookie =
new Cookie("name", "value", shorter, "/", new Date(System.currentTimeMillis() + 100000));
driver.manage().addCookie(cookie);
assertNotNull(driver.manage().getCookieNamed("name"));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment