Search in sources :

Example 41 with Cookie

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();
}
Also used : Cookie(org.openqa.selenium.Cookie)

Example 42 with Cookie

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;
}
Also used : Cookie(org.openqa.selenium.Cookie) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 43 with Cookie

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);
}
Also used : Cookie(org.openqa.selenium.Cookie) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 44 with 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);
}
Also used : Cookie(org.openqa.selenium.Cookie) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 45 with 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"));
}
Also used : Cookie(org.openqa.selenium.Cookie) JsonObject(elemental.json.JsonObject)

Aggregations

Cookie (org.openqa.selenium.Cookie)73 Test (org.junit.Test)26 WebElement (org.openqa.selenium.WebElement)16 WebDriver (org.openqa.selenium.WebDriver)14 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)9 Date (java.util.Date)8 App (com.coveros.selenified.application.App)7 IOException (java.io.IOException)7 AbstractKeycloakTest (org.keycloak.testsuite.AbstractKeycloakTest)7 BasicClientCookie (org.apache.http.impl.cookie.BasicClientCookie)6 Test (org.testng.annotations.Test)6 Collectors (java.util.stream.Collectors)5 BasicCookieStore (org.apache.http.impl.client.BasicCookieStore)5 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)5 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)5 AuthorizeClient (org.gluu.oxauth.client.AuthorizeClient)5 Matchers (org.hamcrest.Matchers)5 Page (org.jboss.arquillian.graphene.page.Page)5 Assert (org.junit.Assert)5 AdminRoles (org.keycloak.models.AdminRoles)5