Example usage for org.openqa.selenium.support.ui ExpectedConditions visibilityOfAllElementsLocatedBy

List of usage examples for org.openqa.selenium.support.ui ExpectedConditions visibilityOfAllElementsLocatedBy

Introduction

In this page you can find the example usage for org.openqa.selenium.support.ui ExpectedConditions visibilityOfAllElementsLocatedBy.

Prototype

public static ExpectedCondition<List<WebElement>> visibilityOfAllElementsLocatedBy(final By locator) 

Source Link

Document

An expectation for checking that all elements present on the web page that match the locator are visible.

Usage

From source file:org.apache.archiva.web.test.RepositoryAdminTest.java

License:Apache License

@Test
public void testManagedRepository() {
    // login( getAdminUsername(), getAdminPassword() );
    WebDriverWait wait = new WebDriverWait(getWebDriver(), 20);
    WebElement el;/*  w  ww  .j a  va  2s .  co m*/
    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("menu-repositories-list-a")));
    tryClick(el, ExpectedConditions.presenceOfElementLocated(By.id("managed-repositories-view-a")),
            "Managed Repositories not activated");
    el = wait.until(
            ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repositories-content']")));
    tryClick(el,
            ExpectedConditions.visibilityOfElementLocated(
                    By.xpath("//table[@id='remote-repositories-table']//td[contains(text(),'central')]")),
            "Remote Repositories View not available");
    el = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[@href='#remote-repository-edit']")));
    el = tryClick(el, ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-save-button")),
            "Repository Save Button not available");

    setFieldValue("id", "myrepoid");
    setFieldValue("name", "My repo name");
    setFieldValue("url", "http://www.repo.org");

    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("remote-repository-save-button")));
    Actions actions = new Actions(getWebDriver());
    actions.moveToElement(el);
    actions.perform();
    ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
    el.click();
    el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repositories-view-a")));
    ((JavascriptExecutor) getWebDriver()).executeScript("arguments[0].scrollIntoView();", el);
    tryClick(By.id("menu-proxy-connectors-list-a"),
            ExpectedConditions
                    .visibilityOfElementLocated(By.id("proxy-connectors-view-tabs-a-network-proxies-grid")),
            "Network proxies not available", 3, 10);
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("main-content"), "Proxy Connectors"));
    // proxy connect
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central"));
    assertTextNotPresent("myrepoid");
    el = wait.until(ExpectedConditions.elementToBeClickable(By.id("proxy-connectors-view-tabs-a-edit")));
    el.click();
    el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("proxy-connector-btn-save")));
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("remote-repository-edit-fieldset")));
    // Another hack, don't know why the normal selectValue() does not work here
    ((JavascriptExecutor) getWebDriver()).executeScript("jQuery('#sourceRepoId').css('display','block')");
    Select select = new Select(getWebDriver().findElement(By.xpath(".//select[@id='sourceRepoId']")));
    select.selectByVisibleText("internal");
    // selectValue( "sourceRepoId", "internal", true );
    // Workaround
    // TODO: Check after upgrade of htmlunit, bootstrap or jquery
    // TODO: Check whats wrong here
    ((JavascriptExecutor) getWebDriver()).executeScript("$('#targetRepoId').show();");
    // End of Workaround
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("targetRepoId")));
    selectValue("targetRepoId", "myrepoid");
    el.click();
    wait.until(
            ExpectedConditions.textToBePresentInElementLocated(By.id("user-messages"), "ProxyConnector added"));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "central"));
    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("proxy-connectors-view"), "myrepoid"));

    tryClick(By.xpath("//i[contains(@class,'icon-resize-vertical')]//ancestor::a"),
            ExpectedConditions.visibilityOfAllElementsLocatedBy(By.id("proxy-connector-edit-order-div")),
            "Edit order view not visible", 3, 10);
    // clickLinkWithXPath( "//i[contains(@class,'icon-resize-vertical')]//ancestor::a");
    // This is needed here for HTMLUnit Tests. Currently do not know why, wait is not working for the
    // list entries down
    // waitPage();
    // el = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("proxy-connector-edit-order-div")));
    assertTextPresent("internal");
    List<WebElement> repos = wait.until(ExpectedConditions
            .numberOfElementsToBe(By.xpath("//div[@id='proxy-connector-edit-order-div']/div"), 2));
    Assert.assertTrue("First repo is myrepo", repos.get(0).getText().contains("myrepoid"));
    Assert.assertTrue("Second repo is central", repos.get(1).getText().contains("central"));

    // works until this point
    /*getSelenium().mouseDown( "xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" );
    getSelenium().mouseMove( "xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" );
    getSelenium().mouseUp( "xpath=//div[@id='proxy-connector-edit-order-div']/div[last()]" );
    Assert.assertTrue( "Second repo is myrepo", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[2]" ).contains( "myrepoid" ));
    Assert.assertTrue( "First repo is central", getSelenium().getText("xpath=//div[@id='proxy-connector-edit-order-div']/div[1]" ).contains( "central" ));
    */
}

From source file:org.eclipse.che.selenium.pageobject.FindText.java

License:Open Source License

public void selectItemInFindInfoPanel(String fileName, String textToFind) {
    List<WebElement> webElementList = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
            .until(ExpectedConditions
                    .visibilityOfAllElementsLocatedBy(By.xpath(String.format(Locators.OCCURRENCE, fileName))));
    for (WebElement webElement : webElementList) {
        if (webElement.getText().equals(textToFind)) {
            webElement.click();/*from w ww.j a  v a  2  s .c o m*/
            break;
        }
    }
}

From source file:org.eclipse.che.selenium.pageobject.FindText.java

License:Open Source License

public void selectItemInFindInfoPanelByDoubleClick(String fileName, String textToFind) {
    List<WebElement> webElementList = new WebDriverWait(seleniumWebDriver, REDRAW_UI_ELEMENTS_TIMEOUT_SEC)
            .until(ExpectedConditions
                    .visibilityOfAllElementsLocatedBy(By.xpath(String.format(Locators.OCCURRENCE, fileName))));
    for (WebElement webElement : webElementList) {
        if (webElement.getText().equals(textToFind)) {
            actionsFactory.createAction(seleniumWebDriver).doubleClick(webElement).perform();
            break;
        }//  w  ww .  ja va 2  s . com
    }
}

From source file:org.eclipse.che.selenium.pageobject.plugins.JavaTestRunnerPluginConsole.java

License:Open Source License

/**
 * wait the FQN of the test class in result tree class that has been launched
 *
 * @param fqn//www .jav  a  2  s .co  m
 */
public void waitFqnOfTesClassInResultTree(String fqn) {
    new WebDriverWait(seleniumWebDriver, MINIMUM_SEC).until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(By.xpath(String.format(TEST_RESULT_TREE_XPATH_TEMPLATE, fqn))));
}

From source file:org.glowroot.agent.webdriver.tests.BasicSmokeIT.java

License:Apache License

@Test
public void shouldCheckJvmPages() throws Exception {
    // given/*from   w w  w. j a v  a 2 s .  c  o m*/
    App app = new App(driver, "http://localhost:" + getUiPort());
    GlobalNavbar globalNavbar = new GlobalNavbar(driver);
    JvmSidebar jvmSidebar = new JvmSidebar(driver);

    app.open();
    globalNavbar.getJvmLink().click();
    // sleep for a second to give time for jvm gauges page to make 2 requests
    // (first to get gauge list and then to get gauge points for default selected gauges)
    Thread.sleep(1000);

    jvmSidebar.getProcessInfoLink().click();

    jvmSidebar.getThreadDumpLink().click();

    jvmSidebar.getHeapDumpLink().click();
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Heap dump']")).click();
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Yes']")).click();
    String heapDumpFileName = Utils
            .withWait(driver, By.xpath("//div[@ng-show='heapDumpResponse']//table//tr[1]/td[2]")).getText();
    if (!new File(heapDumpFileName).delete()) {
        throw new IOException("Could not delete heap dump file: " + heapDumpFileName);
    }
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Check disk space']")).click();
    Utils.withWait(driver, By.xpath("//div[@ng-show='availableDiskSpaceBytes !== undefined']"));

    jvmSidebar.getMBeanTreeLink().click();
    List<WebElement> elements = new WebDriverWait(driver, 30).until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(xpath("//span[@gt-smart-click='toggleMBean(node)']")));
    for (WebElement element : elements) {
        element.click();
    }
    // test the refresh of opened items
    driver.navigate().refresh();
    // need to go back to top of page b/c sidebar links need to be viewable before they can be
    // clicked in chrome and safari drivers
    ((JavascriptExecutor) driver).executeScript("scroll(0, 0)");

    // jvm capabilities is not accessible via config sidebar currently
    String capabilitiesUrl = driver.getCurrentUrl().replace("/jvm/mbean-tree", "/jvm/capabilities");
    driver.navigate().to(capabilitiesUrl);
}

From source file:org.glowroot.tests.BasicSmokeIT.java

License:Apache License

@Test
public void shouldCheckJvmPages() throws Exception {
    App app = app();/*from w ww. j ava  2s  .c o  m*/
    GlobalNavbar globalNavbar = globalNavbar();
    JvmSidebar jvmSidebar = new JvmSidebar(driver);

    app.open();
    globalNavbar.getJvmLink().click();
    // sleep for a second to give time for jvm gauges page to make 2 requests
    // (first to get gauge list and then to get gauge points for default selected gauges)
    Thread.sleep(1000);

    jvmSidebar.getEnvironmentLink().click();

    jvmSidebar.getThreadDumpLink().click();
    // jstack view is not accessible via jvm sidebar currently
    app.open("/jvm/jstack");

    jvmSidebar.getHeapDumpLink().click();
    if (!WebDriverSetup.useCentral) {
        // heap dump is somehow causing cassandra connection to be lost on travis-ci:
        //
        // com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for
        // query failed (tried: /127.0.0.1:9042
        // (com.datastax.driver.core.exceptions.ConnectionException: [/127.0.0.1] Write attempt
        // on defunct connection))
        Utils.withWait(driver, By.xpath("//button[normalize-space()='Heap dump']")).click();
        Utils.withWait(driver, By.xpath("//button[normalize-space()='Yes']")).click();
        String heapDumpFileName = Utils
                .withWait(driver, By.xpath("//div[@ng-show='heapDumpResponse']//table//tr[1]/td[2]")).getText();
        if (!new File(heapDumpFileName).delete()) {
            throw new IOException("Could not delete heap dump file: " + heapDumpFileName);
        }
    }
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Check disk space']")).click();
    Utils.withWait(driver, By.xpath("//div[@ng-show='availableDiskSpaceBytes !== undefined']"));

    jvmSidebar.getHeapHistogramLink().click();

    jvmSidebar.getMBeanTreeLink().click();
    List<WebElement> elements = new WebDriverWait(driver, 30).until(
            ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("gt-mbean-unexpanded-content")));
    for (WebElement element : elements) {
        element.click();
    }
    // test the refresh of opened items
    driver.navigate().refresh();
    if (!(driver instanceof JBrowserDriver)) {
        // need to go back to top of page b/c sidebar links need to be viewable before they can
        // be clicked in chrome and safari drivers
        ((JavascriptExecutor) driver).executeScript("scroll(0, 0)");
    }

    // jvm capabilities is not accessible via config sidebar currently
    app.open("/jvm/capabilities");
}

From source file:org.glowroot.tests.webdriver.BasicSmokeTest.java

License:Apache License

@Test
public void shouldCheckJvmPages() throws Exception {
    // given//  ww w .java2s  . c  o  m
    App app = new App(driver, "http://localhost:" + container.getUiPort());
    GlobalNavbar globalNavbar = new GlobalNavbar(driver);
    JvmSidebar jvmSidebar = new JvmSidebar(driver);

    app.open();
    globalNavbar.getJvmLink().click();
    // sleep for a second to give time for jvm gauges page to make 2 requests
    // (first to get gauge list and then to get gauge points for default selected gauges)
    Thread.sleep(1000);
    jvmSidebar.getMBeanTreeLink().click();
    List<WebElement> elements = new WebDriverWait(driver, 30).until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(xpath("//span[@gt-smart-click='toggleMBean(node)']")));
    for (WebElement element : elements) {
        element.click();
    }
    // test the refresh of opened items
    driver.navigate().refresh();
    // need to go back to top of page b/c sidebar links need to be viewable before they can be
    // clicked in chrome and safari drivers
    ((JavascriptExecutor) driver).executeScript("scroll(0, 0)");

    jvmSidebar.getThreadDumpLink().click();
    jvmSidebar.getHeapDumpLink().click();
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Dump heap']")).click();
    Utils.withWait(driver, By.xpath("//div[@ng-show='heapDumpResponse']"));
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Check disk space']")).click();
    Utils.withWait(driver, By.xpath("//div[@ng-show='checkDiskSpaceResponse']"));
    jvmSidebar.getProcessInfoLink().click();
    jvmSidebar.getSystemPropertiesLink().click();
    // jvm capabilities is not accessible via config sidebar currently
    String capabilitiesUrl = driver.getCurrentUrl().replace("/jvm/system-properties", "/jvm/capabilities");
    driver.navigate().to(capabilitiesUrl);
}

From source file:org.keycloak.quickstart.ArquillianJpaStorageTest.java

License:Apache License

private void waitTillElementPresent(By locator) {
    Graphene.waitGui().withTimeout(60, TimeUnit.SECONDS)
            .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(locator));
}

From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java

License:Open Source License

public static List<WebElement> waitForContainsdataTestIdVisibility(String dataTestId) {
    WebDriverWait wait = new WebDriverWait(driver, 5);
    return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(
            By.xpath("//*[contains (@data-tests-id, '" + dataTestId + "'])")));
}

From source file:org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.java

License:Open Source License

public static List<WebElement> waitForElementsListVisibility(String dataTestId) {
    WebDriverWait wait = new WebDriverWait(driver, 3 * 60);
    List<WebElement> findElements = wait.until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(By.xpath("//*[@data-tests-id='" + dataTestId + "']")));
    if (findElements.size() > 0) {
        return findElements;
    }/*from w w w  . j a  va  2  s  .c o  m*/
    System.out.println("Elements not Exist!");
    return null;
}