Last active
June 4, 2016 07:03
-
-
Save slawekradzyminski/d3d02f4c6a52b151552da58f3fad185b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Request(WebDriver driver) { | |
this.driver = driver; | |
} | |
private void addCookies(BasicHttpContext httpContext) { | |
BasicCookieStore cookies = getCurrentDriverCookies(driver.manage().getCookies()); | |
httpContext.setAttribute(HttpClientContext.COOKIE_STORE, cookies); | |
} | |
private BasicCookieStore getCurrentDriverCookies(Set<Cookie> cookies) { | |
BasicCookieStore mimicWebDriverCookieStore = new BasicCookieStore(); | |
for (Cookie seleniumCookie : cookies) { | |
BasicClientCookie duplicateCookie = new BasicClientCookie(seleniumCookie.getName(), seleniumCookie.getValue()); | |
duplicateCookie.setDomain(seleniumCookie.getDomain()); | |
duplicateCookie.setSecure(seleniumCookie.isSecure()); | |
duplicateCookie.setExpiryDate(seleniumCookie.getExpiry()); | |
duplicateCookie.setPath(seleniumCookie.getPath()); | |
mimicWebDriverCookieStore.addCookie(duplicateCookie); | |
} | |
return mimicWebDriverCookieStore; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment