protected ReturnedCookie createCookie() { if (rawCookie == null) { return null; } String name = (String) rawCookie.get("name"); String value = (String) rawCookie.get("value"); String path = (String) rawCookie.get("path"); String domain = (String) rawCookie.get("domain"); Boolean secure = (Boolean) rawCookie.get("secure"); return new ReturnedCookie(name, value, domain, path, null, secure); }
@Override protected void validate() { super.validate(); String domain = getDomain(); if (domain != null && !"".equals(domain)) { try { String domainToUse = domain.startsWith("http") ? domain : "http://" + domain; URL url = new URL(domainToUse); InetAddress.getByName(url.getHost()); } catch (MalformedURLException e) { throw new IllegalArgumentException(String.format("URL not valid: %s", domain)); } catch (UnknownHostException e) { throw new IllegalArgumentException(String.format("Domain does not exist: %s", domain)); } } }
protected ReturnedCookie createCookie() { if (rawCookie == null) { return null; } String name = (String) rawCookie.get("name"); String value = (String) rawCookie.get("value"); String path = (String) rawCookie.get("path"); String domain = (String) rawCookie.get("domain"); Boolean secure = (Boolean) rawCookie.get("secure"); return new ReturnedCookie(name, value, domain, path, null, secure, getDriver().getCurrentUrl()); }
cookies.add(new ReturnedCookie(attributesMap.get("name"), attributesMap.get("value"), attributesMap.get("domain"), attributesMap.get("path"), expires, Boolean.parseBoolean(attributesMap.get("secure"))));
@SuppressWarnings({"unchecked"}) public Set<Cookie> getCookies() { Object returned = execute("getAllCookies").getValue(); try { List<Map<String, Object>> cookies = new JsonToBeanConverter().convert(List.class, returned); Set<Cookie> toReturn = new HashSet<Cookie>(); for (Map<String, Object> rawCookie : cookies) { String name = (String) rawCookie.get("name"); String value = (String) rawCookie.get("value"); String path = (String) rawCookie.get("path"); String domain = (String) rawCookie.get("domain"); Boolean secure = (Boolean) rawCookie.get("secure"); toReturn.add(new ReturnedCookie(name, value, domain, path, null, secure)); } return toReturn; } catch (Exception e) { throw new WebDriverException(e); } }
public Set<Cookie> getCookies() { String currentUrl = getCurrentHost(); PointerByReference wrapper = new PointerByReference(); int result = lib.wdGetCookies(driver, wrapper); errors.verifyErrorCode(result, "Unable to extract visible cookies"); Set<Cookie> toReturn = new HashSet<Cookie>(); String allDomainCookies = new StringWrapper(lib, wrapper).toString(); String[] cookies = allDomainCookies.split("; "); for (String cookie : cookies) { String[] parts = cookie.split("="); if (parts.length != 2) { continue; } toReturn.add(new ReturnedCookie(parts[0], parts[1], currentUrl, "", null, false)); } return toReturn; }
public Set<Cookie> getCookies() { Set<org.apache.commons.httpclient.Cookie> rawCookies = webClient.getCookieManager().getCookies(getHostName()); Set<Cookie> retCookies = new HashSet<Cookie>(); for(org.apache.commons.httpclient.Cookie c : rawCookies) { if (c.getPath() != null && getPath().startsWith(c.getPath())) { retCookies.add(new ReturnedCookie(c.getName(), c.getValue(), c.getDomain(), c.getPath(), c.getExpiryDate(), c.getSecure())); } } return retCookies; }