Search in sources :

Example 61 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class BBBUtil method revokeApplicationsAccess.

public static void revokeApplicationsAccess(WebDriver webDriver) {
    List<String> clientIds = new ArrayList<String>();
    Properties prop = SystemPropertiesHelper.getProperties();
    String clientId1 = prop.getProperty("org.orcid.web.testClient1.clientId");
    if (!PojoUtil.isEmpty(clientId1)) {
        clientIds.add(clientId1);
    }
    String clientId2 = prop.getProperty("org.orcid.web.testClient2.clientId");
    if (!PojoUtil.isEmpty(clientId2)) {
        clientIds.add(clientId2);
    }
    String userName = prop.getProperty("org.orcid.web.testUser1.username");
    String password = prop.getProperty("org.orcid.web.testUser1.password");
    String baseUrl = "https://localhost:8443/orcid-web";
    if (!PojoUtil.isEmpty(prop.getProperty("org.orcid.web.baseUri"))) {
        baseUrl = prop.getProperty("org.orcid.web.baseUri");
    }
    webDriver.get(baseUrl + "/userStatus.json?logUserOut=true");
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
    webDriver.get(baseUrl + "/my-orcid");
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    SigninTest.signIn(webDriver, userName, password);
    // Switch to accounts settings page
    By accountSettingsMenuLink = By.id("accountSettingMenuLink");
    BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(accountSettingsMenuLink), webDriver);
    webDriver.get(baseUrl + "/account");
    BBBUtil.extremeWaitFor(BBBUtil.documentReady(), webDriver);
    BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
    try {
        boolean lookAgain = false;
        do {
            // Look for each revoke app button
            By revokeAppBtn = By.id("revokeAppBtn");
            BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
            List<WebElement> appsToRevoke = webDriver.findElements(revokeAppBtn);
            boolean elementFound = false;
            // client id
            for (WebElement appElement : appsToRevoke) {
                String nameAttribute = appElement.getAttribute("name");
                if (clientIds.contains(nameAttribute)) {
                    BBBUtil.ngAwareClick(appElement, webDriver);
                    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
                    // Wait for the revoke button
                    By confirmRevokeAppBtn = By.id("confirmRevokeAppBtn");
                    BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(confirmRevokeAppBtn), webDriver);
                    BBBUtil.ngAwareClick(webDriver.findElement(confirmRevokeAppBtn), webDriver);
                    BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
                    BBBUtil.noCboxOverlay(webDriver);
                    BBBUtil.extremeWaitFor(BBBUtil.angularHasFinishedProcessing(), webDriver);
                    // may need to put sleep back here
                    elementFound = true;
                    break;
                }
            }
            if (elementFound) {
                lookAgain = true;
            } else {
                lookAgain = false;
            }
        } while (lookAgain);
    } catch (Exception e) {
    // If it fail is because it couldn't find any other application
    } finally {
        logUserOut(baseUrl, webDriver);
    }
}
Also used : By(org.openqa.selenium.By) ArrayList(java.util.ArrayList) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) Properties(java.util.Properties) WebElement(org.openqa.selenium.WebElement) NoSuchElementException(org.openqa.selenium.NoSuchElementException)

Example 62 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class OauthAuthorizationPageHelper method clickAuthorizeOnAuthorizeScreen.

private static void clickAuthorizeOnAuthorizeScreen(final WebDriver webDriver) {
    By userIdElementLocator = By.id("authorize");
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
    WebElement authorizeButton = webDriver.findElement(By.id("authorize"));
    authorizeButton.click();
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {

        public Boolean apply(WebDriver d) {
            return d.getTitle().equals("ORCID Playground");
        }
    });
}
Also used : WebDriver(org.openqa.selenium.WebDriver) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) WebElement(org.openqa.selenium.WebElement)

Example 63 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class OauthAuthorizationPageHelper method loginAndAuthorize.

public static String loginAndAuthorize(String baseUrl, String clientId, String redirectUri, String scopes, String stateParam, String userId, String password, boolean longLife, Map<String, String> params, WebDriver webDriver) {
    String formattedAuthorizationScreen = String.format(authorizationScreenUrl, baseUrl, clientId, scopes, redirectUri);
    if (!PojoUtil.isEmpty(stateParam)) {
        formattedAuthorizationScreen += "&state=" + stateParam;
    }
    if (params != null) {
        for (String key : params.keySet()) {
            formattedAuthorizationScreen += "&" + key + "=" + params.get(key);
        }
    }
    formattedAuthorizationScreen += "#show_login";
    webDriver.get(formattedAuthorizationScreen);
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
    BBBUtil.extremeWaitFor(ExpectedConditions.presenceOfElementLocated(By.xpath("//input[@name='userId']")), webDriver);
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    By userIdElementLocator = By.id("userId");
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.documentReady());
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    WebElement userIdElement = webDriver.findElement(userIdElementLocator);
    userIdElement.sendKeys(userId);
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    WebElement passwordElement = webDriver.findElement(By.id("password"));
    passwordElement.sendKeys(password);
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
    if (!longLife) {
        //     disablePersistentToken
        WebElement persistentElement = webDriver.findElement(By.id("enablePersistentToken"));
        if (persistentElement.isDisplayed()) {
            if (persistentElement.isSelected()) {
                BBBUtil.ngAwareClick(persistentElement, webDriver);
            }
            (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS, BBBUtil.SLEEP_MILLISECONDS)).until(BBBUtil.angularHasFinishedProcessing());
        }
    }
    (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(ExpectedConditions.visibilityOfElementLocated(By.id("login-authorize-button")));
    try {
        BBBUtil.ngAwareClick(webDriver.findElement(By.id("login-authorize-button")), webDriver);
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {

            public Boolean apply(WebDriver d) {
                return d.getTitle().equals("ORCID Playground");
            }
        });
    } catch (TimeoutException e) {
        //It might be the case that we are already in the ORCID Playground page, so, lets check for that case
        (new WebDriverWait(webDriver, BBBUtil.TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {

            public Boolean apply(WebDriver d) {
                return d.getTitle().equals("ORCID Playground");
            }
        });
    }
    return webDriver.getCurrentUrl();
}
Also used : WebDriver(org.openqa.selenium.WebDriver) By(org.openqa.selenium.By) WebDriverWait(org.openqa.selenium.support.ui.WebDriverWait) ExpectedCondition(org.openqa.selenium.support.ui.ExpectedCondition) WebElement(org.openqa.selenium.WebElement) TimeoutException(org.openqa.selenium.TimeoutException)

Example 64 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class BlackBoxBase method changeKeywordsVisibility.

public static void changeKeywordsVisibility(Visibility visibility) {
    int index = getPrivacyIndex(visibility);
    String keywordsVisibilityXpath = "//div[@ng-repeat='keyword in keywordsForm.keywords']//ul[@class='privacyToggle']/li[" + index + "]";
    BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(keywordsVisibilityXpath)), webDriver);
    List<WebElement> visibilityElements = webDriver.findElements(By.xpath(keywordsVisibilityXpath));
    for (WebElement webElement : visibilityElements) {
        BBBUtil.ngAwareClick(webElement, webDriver);
    }
}
Also used : WebElement(org.openqa.selenium.WebElement)

Example 65 with WebElement

use of org.openqa.selenium.WebElement in project ORCID-Source by ORCID.

the class BlackBoxBase method changeResearcherUrlsVisibility.

public static void changeResearcherUrlsVisibility(Visibility visibility) {
    int index = getPrivacyIndex(visibility);
    String researcherUrlsVisibilityXpath = "//div[@ng-repeat='website in websitesForm.websites']//ul[@class='privacyToggle']/li[" + index + "]";
    BBBUtil.extremeWaitFor(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(researcherUrlsVisibilityXpath)), webDriver);
    List<WebElement> visibilityElements = webDriver.findElements(By.xpath(researcherUrlsVisibilityXpath));
    for (WebElement webElement : visibilityElements) {
        BBBUtil.ngAwareClick(webElement, webDriver);
    }
}
Also used : WebElement(org.openqa.selenium.WebElement)

Aggregations

WebElement (org.openqa.selenium.WebElement)520 Test (org.junit.Test)96 WebDriver (org.openqa.selenium.WebDriver)85 PublicAtsApi (com.axway.ats.common.PublicAtsApi)57 Actions (org.openqa.selenium.interactions.Actions)55 FirefoxDriver (org.openqa.selenium.firefox.FirefoxDriver)46 WebDriverWait (org.openqa.selenium.support.ui.WebDriverWait)40 By (org.openqa.selenium.By)36 URL (java.net.URL)35 RunAsClient (org.jboss.arquillian.container.test.api.RunAsClient)34 RealHtmlElementState (com.axway.ats.uiengine.utilities.realbrowser.html.RealHtmlElementState)30 JavascriptExecutor (org.openqa.selenium.JavascriptExecutor)21 NoSuchElementException (org.openqa.selenium.NoSuchElementException)21 HiddenHtmlElementState (com.axway.ats.uiengine.utilities.hiddenbrowser.HiddenHtmlElementState)19 ArrayList (java.util.ArrayList)18 SeleniumOperationException (com.axway.ats.uiengine.exceptions.SeleniumOperationException)13 Select (org.openqa.selenium.support.ui.Select)13 TimeoutException (org.openqa.selenium.TimeoutException)12 VisualEditorPageObject (com.wikia.webdriver.pageobjectsfactory.pageobject.visualeditor.VisualEditorPageObject)11 List (java.util.List)10