Example usage for org.openqa.selenium Cookie Cookie

List of usage examples for org.openqa.selenium Cookie Cookie

Introduction

In this page you can find the example usage for org.openqa.selenium Cookie Cookie.

Prototype

public Cookie(String name, String value, String domain, String path, Date expiry, boolean isSecure) 

Source Link

Document

Creates a non-httpOnly cookie.

Usage

From source file:com.machinepublishers.jbrowserdriver.OptionsServer.java

License:Apache License

private static Cookie convert(org.apache.http.cookie.Cookie in) {
    return new Cookie(in.getName(), in.getValue(), in.getDomain(), in.getPath(), in.getExpiryDate(),
            in.isSecure());//from w  w w . j a  va 2 s.c o  m
}

From source file:com.opera.core.systems.scope.services.ums.CookieManager.java

License:Apache License

public Set<Cookie> getCookie(String domain, String path) {
    if (domain == null) {
        throw new NullPointerException("Domain can not be null");
    }/*  w w w.j av a 2  s .  c o  m*/

    GetCookieArg.Builder arg = GetCookieArg.newBuilder();
    arg.setDomain(domain);

    if (path != null) {
        arg.setPath(path);
    }

    Response response = executeCommand(CookieManagerCommand.GET_COOKIE, arg);
    CookieList.Builder builder = CookieList.newBuilder();
    buildPayload(response, builder);
    CookieList list = builder.build();

    List<com.opera.core.systems.scope.protos.CookieMngProtos.Cookie> cookies = list.getCookieListList();
    Set<Cookie> result = new HashSet<Cookie>(cookies.size());

    for (com.opera.core.systems.scope.protos.CookieMngProtos.Cookie cookie : cookies) {
        result.add(new Cookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(),
                new Date(cookie.getExpires()), cookie.getIsSecure()));
    }

    return result;

}

From source file:com.opera.core.systems.scope.stp.services.ScopeCookieManager.java

License:Apache License

public Set<Cookie> getCookie(String domain, String path) {
    checkNotNull(domain, "Domain cannot be null");

    GetCookieArg.Builder arg = GetCookieArg.newBuilder();
    arg.setDomain(domain);//  w w w . j  a va2  s  .c  o  m

    if (path != null) {
        arg.setPath(path);
    }

    Response response = executeMessage(CookieManagerMessage.GET_COOKIE, arg);
    CookieList.Builder builder = CookieList.newBuilder();
    buildPayload(response, builder);
    CookieList list = builder.build();

    List<CookieMngProtos.Cookie> cookies = list.getCookieListList();
    Set<Cookie> result = Sets.newHashSet();

    for (CookieMngProtos.Cookie cookie : cookies) {
        result.add(new Cookie(cookie.getName(), cookie.getValue(), cookie.getDomain(), cookie.getPath(),
                new Date(cookie.getExpires()), cookie.getIsSecure()));
    }

    return result;

}

From source file:org.uiautomation.ios.context.BaseWebInspector.java

License:Apache License

public List<Cookie> getCookies() {

    List<Cookie> res = new ArrayList<Cookie>();
    JSONObject o = sendCommand(Page.getCookies());
    JSONArray cookies = o.optJSONArray("cookies");
    if (cookies != null) {
        for (int i = 0; i < cookies.length(); i++) {
            JSONObject cookie = cookies.optJSONObject(i);
            String name = cookie.optString("name");
            String value = cookie.optString("value");
            String domain = cookie.optString("domain");
            String path = cookie.optString("path");
            Date expiry = new Date(cookie.optLong("expires"));
            boolean isSecure = cookie.optBoolean("secure");
            Cookie c = new Cookie(name, value, domain, path, expiry, isSecure);
            res.add(c);//ww  w.  j  av  a2  s  .  c  om
        }
        return res;
    } else {
        // TODO
    }
    return null;
}