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

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

Introduction

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

Prototype

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

Source Link

Document

An expectation for checking that there is at least one element present on a web page.

Usage

From source file:swift.selenium.WebHelper.java

License:Open Source License

public static List<WebElement> getElementsByType(String controlId, String controlName, String controlType,
        String imageType, String controlValue) throws Exception {

    List<WebElement> controlList = null;
    ControlIdEnum controlID = ControlIdEnum.valueOf(controlId);
    try {// ww  w.j a v a 2  s .co m
        switch (controlID) {

        case Id:
        case HTMLID:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(controlName)));
            break;

        case Name:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.name(controlName)));
            break;

        case XPath:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(controlName)));
            break;

        case ClassName:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className(controlName)));
            break;

        case TagText:
        case TagValue:
        case TagOuterText:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.tagName(imageType)));
            break;

        case LinkText:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(controlName)));
            break;

        case LinkValue:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(controlValue)));
            break;

        case CSSSelector:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(controlName)));
            break;

        default:
            break;
        }
        return controlList;
    } catch (Exception ex) {
        throw new Exception(ex.getMessage());
    }
}

From source file:SwiftSeleniumWeb.WebHelper.java

License:Open Source License

/**
 * Get list of elements//from w ww.jav  a2  s .  com
 * 
 * @param controlId
 * @param controlName
 * @param controlType
 * @param imageType
 * @param controlValue
 * @return
 * @throws Exception
 */
public static List<WebElement> getElementsByType(String controlId, String controlName, String controlType,
        String imageType, String controlValue) throws Exception {

    List<WebElement> controlList = null;
    ControlIdEnum controlID = ControlIdEnum.valueOf(controlId);
    try {
        switch (controlID) {

        case Id:
        case HTMLID:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(controlName)));
            break;

        case Name:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.name(controlName)));
            break;

        case XPath:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.xpath(controlName)));
            break;

        case ClassName:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className(controlName)));
            break;

        case TagText:
        case TagValue:
        case TagOuterText:
            controlList = wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.tagName(imageType)));
            break;

        case LinkText:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(controlName)));
            break;

        case LinkValue:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.linkText(controlValue)));
            break;

        case CSSSelector:
            controlList = wait
                    .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.cssSelector(controlName)));
            break;

        default:
            break;
        }
        return controlList;
    } catch (Exception ex) {
        throw new Exception(ex.getMessage());
    }
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public List<WebElement> waitForExpectedElements(final By by) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), DRIVER_WAIT_TIME);
    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by));
    return getDriver().findElements(by);
}

From source file:test.nov21.configuration.AbstractPage.java

License:Open Source License

public List<WebElement> waitForExpectedElements(final By by, int timeout) {
    Wait<WebDriver> wait = new WebDriverWait(getDriver(), timeout);
    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(by));
    return getDriver().findElements(by);
}

From source file:uk.ac.ebi.atlas.acceptance.selenium.pages.HeatmapTablePage.java

License:Apache License

public BioEntityPage clickGeneName(int zeroBasedGeneNameIndex) {
    geneNames.get(zeroBasedGeneNameIndex).click();

    WebDriverWait wait = new WebDriverWait(driver, 15L);
    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id("accordion")));

    return new BioEntityPage(driver);
}

From source file:webapp.view.ViewTest.java

License:BSD License

@Test
public void viewHomePage() {

    // Load the homepage of the bookstore
    driver.get("http://localhost:8080/" + APP_CONTEXT);

    // Wait for all elements with class "categoryDropdownItem" to load
    // Once they load, store them as a list of web-element objects
    List<WebElement> categoryItems = wait
            .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("categoryBox")));

    // Click on the 3rd category
    categoryItems.get(2).click();/*from  w  ww.jav  a  2s .c  om*/

    wait.until(ExpectedConditions.urlContains("category"));

    validatePageUrl("/" + APP_CONTEXT + "/category");
}

From source file:webapp.view.ViewTest.java

License:BSD License

@Test
public void selectedCategoryButton() {
    driver.get("http://localhost:8080/" + APP_CONTEXT + "/category");

    List<WebElement> categoryButtons = wait
            .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("categoryButton")));

    int selected = 0;
    for (WebElement categoryButton : categoryButtons) {

        String classNames = categoryButton.getAttribute("className");
        assertNotNull(classNames);//from  w ww .j  av a 2 s.  co  m
        assertTrue(classNames.contains("categoryButton"), "categoryButton is a required class");

        final String categoryButtonId = categoryButton.getAttribute("id");
        if (categoryButtonId != null && categoryButtonId.length() > 0) {
            if (selected > 0 && "selectedCategory".equals(categoryButtonId)) {
                fail("Only one category button should be selected");
            }
            assertEquals("selectedCategory", categoryButtonId,
                    "Found a strange category id: " + categoryButtonId);
            selected++;
        }
    }
    assertEquals(1, selected, "There must be a selected category");

}

From source file:webapp.view.ViewTest.java

License:BSD License

@Test
public void categoryPageHasAtLeast4CategoryButtons() {
    // Load the homepage of the bookstore
    driver.get("http://localhost:8080/" + APP_CONTEXT + "/category");

    List<WebElement> categoryButtons = wait
            .until(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("categoryButton")));

    assertTrue(categoryButtons.size() >= 4);
}