use of org.openqa.selenium.Cookie in project wechat by dllwh.
the class SinaWeiboCN method concatCookie.
/**
* ----------------------------------------------------- Fields start
*/
/**
* ----------------------------------------------------- Fields end
*/
/**
* ----------------------------------------------- [私有方法]
*/
/**
* @方法描述: 获取cookie
* @param driver
* @param sb
* @return
*/
private static String concatCookie(HtmlUnitDriver driver) {
Set<Cookie> cookieSet = driver.manage().getCookies();
driver.close();
StringBuilder sb = new StringBuilder();
for (Cookie cookie : cookieSet) {
sb.append(cookie.getName() + "=" + cookie.getValue() + ";");
}
return sb.toString();
}
use of org.openqa.selenium.Cookie in project ats-framework by Axway.
the class AbstractHtmlEngine method getCookies.
/**
* Get all the cookies for the current domain. This is the equivalent of calling "document.cookie" and parsing the result
*
* @return {@link com.axway.ats.uiengine.elements.html.Cookie Cookie}s array
*/
@PublicAtsApi
public com.axway.ats.uiengine.elements.html.Cookie[] getCookies() {
Set<Cookie> cookies = webDriver.manage().getCookies();
com.axway.ats.uiengine.elements.html.Cookie[] cookiesArr = new com.axway.ats.uiengine.elements.html.Cookie[cookies.size()];
int i = 0;
for (Cookie c : cookies) {
cookiesArr[i++] = new com.axway.ats.uiengine.elements.html.Cookie(c.getName(), c.getValue(), c.getDomain(), c.getPath(), c.getExpiry(), c.isSecure());
}
return cookiesArr;
}
use of org.openqa.selenium.Cookie in project ats-framework by Axway.
the class AbstractHtmlEngine method setCookie.
/**
* @param name the name of the cookie. May not be null or an empty string.
* @param value the cookie value. May not be null.
* @param domain the domain the cookie is visible to.
* @param path the path the cookie is visible to. If left blank or set to null, will be set to
* "/".
* @param expiry the cookie's expiration date; may be null.
* @param isSecure whether this cookie requires a secure connection.
*/
@PublicAtsApi
public void setCookie(String name, String value, String domain, String path, Date expiry, boolean isSecure) {
Cookie cookie = new Cookie(name, value, domain, path, expiry, isSecure);
webDriver.manage().addCookie(cookie);
}
use of org.openqa.selenium.Cookie in project ats-framework by Axway.
the class AbstractHtmlEngine method setCookie.
/**
* @param cookieName the name of the cookie. May not be null or an empty string.
* @param cookieValue the cookie value. May not be null.
*/
@PublicAtsApi
public void setCookie(String cookieName, String cookieValue) {
Cookie cookie = new Cookie(cookieName, cookieValue);
webDriver.manage().addCookie(cookie);
}
use of org.openqa.selenium.Cookie in project flow by vaadin.
the class SecurityIT method checkJwtUsername.
private void checkJwtUsername(String expectedUsername) {
Cookie jwtCookie = getJwtCookie();
Assert.assertNotNull(jwtCookie);
String payload = jwtCookie.getValue().split("\\.")[1];
JsonObject payloadJson = Json.parse(new String(Base64.getUrlDecoder().decode(payload)));
Assert.assertEquals(expectedUsername, payloadJson.getString("sub"));
}
Aggregations