use of org.openqa.selenium.InvalidCookieDomainException in project selenium_java by sergueik.
the class GoogleDriveTest method useCookieTest.
// @Ignore
@Test
public void useCookieTest() throws Exception {
doLogin();
System.err.println("Getting the cookies");
Set<Cookie> cookies = driver.manage().getCookies();
System.err.println("Closing the browser");
wait = null;
System.err.println("re-open the browser, about to use the session cookies");
driver.close();
driver = new FirefoxDriver();
// re-initialize wait object
wait = new WebDriverWait(driver, flexibleWait);
wait.pollingEvery(polling, TimeUnit.MILLISECONDS);
System.err.println("Navigating to " + baseURL);
driver.get(baseURL);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
System.err.println("Loading cookies");
for (Cookie cookie : cookies) {
if (debug) {
System.err.println(formatter.format("Name: '%s'\n" + "Value: '%s'\n" + "Domain: '%s'\n" + "Path: '%s'\n" + "Expiry: '%tc'\n" + "Secure: '%b'\n" + "HttpOnly: '%b'\n" + "\n", cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(), cookie.getExpiry(), cookie.isSecure(), cookie.isHttpOnly()).toString());
}
try {
driver.manage().addCookie(cookie);
} catch (InvalidCookieDomainException e) {
// ignore the exception
}
}
driver.get(baseURL);
driver.navigate().refresh();
System.err.println("Waiting for inbox");
/*
* try { wait.until(ExpectedConditions.urlContains("#inbox")); } catch
* (TimeoutException | UnreachableBrowserException e) {
* verificationErrors.append(e.toString()); }
*/
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
}
doLogout();
}
Aggregations