use of org.openqa.selenium.support.ui.WebDriverWait in project oxAuth by GluuFederation.
the class BaseTest method authenticateResourceOwnerAndDenyAccess.
public AuthorizationResponse authenticateResourceOwnerAndDenyAccess(String authorizeUrl, AuthorizationRequest authorizationRequest, String userId, String userSecret) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authenticateResourceOwnerAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
WebElement usernameElement = driver.findElement(By.name(loginFormUsername));
WebElement passwordElement = driver.findElement(By.name(loginFormPassword));
WebElement loginButton = driver.findElement(By.name(loginFormLoginButton));
if (userId != null) {
usernameElement.sendKeys(userId);
}
passwordElement.sendKeys(userSecret);
loginButton.click();
String authorizationResponseStr = driver.getCurrentUrl();
WebElement doNotAllowButton = driver.findElement(By.name(authorizeFormDoNotAllowButton));
final String previousURL = driver.getCurrentUrl();
doNotAllowButton.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("authenticateResourceOwnerAndDenyAccess: sessionState:" + sessionState);
stopSelenium();
AuthorizationResponse authorizationResponse = new AuthorizationResponse(authorizationResponseStr);
if (authorizationRequest.getRedirectUri() != null && authorizationRequest.getRedirectUri().equals(authorizationResponseStr)) {
authorizationResponse.setResponseMode(ResponseMode.FORM_POST);
}
authorizationResponse.setSessionState(sessionState);
authorizeClient.setResponse(authorizationResponse);
showClientUserAgent(authorizeClient);
return authorizationResponse;
}
use of org.openqa.selenium.support.ui.WebDriverWait in project oxAuth by GluuFederation.
the class BaseTest method authorizationRequestAndDenyAccess.
public AuthorizationResponse authorizationRequestAndDenyAccess(String authorizeUrl, AuthorizationRequest authorizationRequest) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authorizationRequestAndDenyAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
WebElement doNotAllowButton = driver.findElement(By.name(authorizeFormDoNotAllowButton));
final String previousURL = driver.getCurrentUrl();
doNotAllowButton.click();
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return (d.getCurrentUrl() != previousURL);
}
});
String authorizationResponseStr = driver.getCurrentUrl();
Cookie sessionStateCookie = driver.manage().getCookieNamed("session_state");
String sessionState = null;
if (sessionStateCookie != null) {
sessionState = sessionStateCookie.getValue();
}
System.out.println("authorizationRequestAndDenyAccess: 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;
}
use of org.openqa.selenium.support.ui.WebDriverWait in project oxAuth by GluuFederation.
the class BaseTest method authorizationRequestAndGrantAccess.
public AuthorizationResponse authorizationRequestAndGrantAccess(String authorizeUrl, AuthorizationRequest authorizationRequest) {
String authorizationRequestUrl = authorizeUrl + "?" + authorizationRequest.getQueryString();
AuthorizeClient authorizeClient = new AuthorizeClient(authorizeUrl);
authorizeClient.setRequest(authorizationRequest);
System.out.println("authorizationRequestAndGrantAccess: authorizationRequestUrl:" + authorizationRequestUrl);
startSelenium();
driver.navigate().to(authorizationRequestUrl);
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("authorizationRequestAndGrantAccess: 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;
}
use of org.openqa.selenium.support.ui.WebDriverWait in project geode by apache.
the class PulseTestUtils method verifyElementPresentById.
public static void verifyElementPresentById(String id) {
WebDriverWait wait = new WebDriverWait(getDriver(), maxWaitTime, 500);
wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(id)));
}
use of org.openqa.selenium.support.ui.WebDriverWait in project geode by apache.
the class WebDriverRule method login.
private void login() {
WebElement userNameElement = waitForElementById("user_name", 60);
WebElement passwordElement = waitForElementById("user_password");
userNameElement.sendKeys(username);
passwordElement.sendKeys(password);
passwordElement.submit();
driver.get(getPulseURL() + "clusterDetail.html");
WebElement userNameOnPulsePage = (new WebDriverWait(driver, 30)).until(new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.id("userName"));
}
});
assertNotNull(userNameOnPulsePage);
}
Aggregations