Search in sources :

Example 16 with WebDriverWait

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

Example 17 with WebDriverWait

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

Example 18 with WebDriverWait

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

Example 19 with WebDriverWait

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

Example 20 with WebDriverWait

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);
}
Also used : WebDriver(org.openqa.selenium.WebDriver) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Aggregations

WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)556 WebElement (org.openqa.selenium.WebElement)173 WebDriver (org.openqa.selenium.WebDriver)139 Test (org.junit.Test)88 By (org.openqa.selenium.By)58 Actions (org.openqa.selenium.interactions.Actions)54 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)47 TimeoutException (org.openqa.selenium.TimeoutException)41 ExpectedCondition (org.openqa.selenium.support.ui.ExpectedCondition)38 IOException (java.io.IOException)30 List (java.util.List)27 Wait (org.openqa.selenium.support.ui.Wait)25 BeforeClass (org.junit.BeforeClass)24 NgWebDriver (com.github.sergueik.jprotractor.NgWebDriver)21 ArrayList (java.util.ArrayList)21 WebDriverException (org.openqa.selenium.WebDriverException)21 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)21 Dimension (org.openqa.selenium.Dimension)20 File (java.io.File)18 NoSuchElementException (org.openqa.selenium.NoSuchElementException)16