use of org.openqa.selenium.Cookie in project selenium-tests by Wikia.
the class WikiBasePageObject method loginAs.
public String loginAs(String userName, String password, String wikiURL) {
String token = Helios.getAccessToken(userName, password);
driver.manage().addCookie(new Cookie("access_token", token, String.format(".%s", Configuration.getEnvType().getWikiaDomain()), null, null));
if (driver.getCurrentUrl().contains("Logout")) {
driver.get(wikiURL);
} else {
refreshPageAddingCacheBuster();
}
this.verifyUserLoggedIn(userName);
PageObjectLogging.log("loginCookie", "user was logged in by by helios using access token: " + token, true);
logMercuryUserId();
return token;
}
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 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 oxAuth by GluuFederation.
the class BaseTest method authenticateResourceOwner.
/**
* The authorization server authenticates the resource owner (via the user-agent)
* No authorization page.
*/
public AuthorizationResponse authenticateResourceOwner(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret, boolean cleanupCookies) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authenticateResourceOwner: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
if (cleanupCookies) {
System.out.println("authenticateResourceOwner: Cleaning cookies");
deleteAllCookies();
}
driver.navigate().to(authorizationRequestUrl);
if (userSecret != null) {
if (userId != null) {
WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
usernameElement.sendKeys(userId);
}
WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
passwordElement.sendKeys(userSecret);
WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
loginButton.click();
}
String authorizationResponseStr = driver.getCurrentUrl();
/*WebElement allowButton = driver.findElement(By.name(authorizeFormAllowButton));
final String previousURL = driver.getCurrentUrl();
allowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}
});
authorizationResponseStr = driver.getCurrentUrl();*/
Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
String sessionState = null;
if (sessionStateCookie != null) {
sessionState = sessionStateCookie.getValue();
}
System.out.println("authenticateResourceOwner: sessionState:" + sessionState);
stopSelenium();
AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
}
authorizeClient.setResponse(authorizationResponse);
showClientUserAgent(authorizeClient);
return authorizationResponse;
}
Aggregations