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:ru.mystamps.web.tests.page.AddSeriesPage.java

License:Open Source License

public List<String> getCountryFieldValues() {
    List<WebElement> selectizedFields = getElementsByClassName("selectize-input");
    Validate.isTrue(selectizedFields.size() == 1,
            "At page for series creation must be exactly one selectized field");

    selectizedFields.get(0).click();//from ww  w. j  av a  2s. c  om

    return new WebDriverWait(driver, WAITING_FOR_ELEMENT_TIMEOUT)
            .until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath(COUNTRY_OPTION_LOCATOR)))
            .stream().map(WebElement::getText).collect(toList());
}

From source file:tamil.selenium.maven.Basicactioncmds.java

@Test
public void k4s() {

    //Maximize Window 
    driver.manage().window().maximize();

    //Goto Advance.kno.com
    driver.get("https://advance.kno.com");
    System.out.println(driver.getCurrentUrl());

    //Login //from   ww w  . j a  va2  s.c  o m
    driver.findElement(By.id("email")).sendKeys("tamil");
    driver.findElement(By.id("password")).sendKeys("123456");
    //driver.findElement(By.linkText("Sign In")).click();
    driver.findElement(By.cssSelector("div[class='field btn-container'] > a")).click();

    WebDriverWait wait = new WebDriverWait(driver, 40);
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("user-name")));

    //Check User Report & Content Report
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'User Report')]")).isDisplayed(),
            "Unable to find text - User Report");
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Content Report')]")).isDisplayed(),
            "Unable to find text - Content Report");

    //1.Click Report to collapse
    driver.findElement(By.xpath("//a[contains(.,'Report')]")).click();
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.cssSelector(".section.collapse-menu")));
    //Verify Collapse
    if (driver.findElement(By.cssSelector(".section.collapse-menu")).isDisplayed()) {
        System.out.println("REPORT is collapsed");
    } else {
        System.out.println("REPORT is not collapsed");
    }
    wait.until(
            ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//a[contains(.,'Manage Books')]")));
    //Check Allocate Licenses & Distribute Books
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Allocate Licenses')]")).isDisplayed(),
            "Unable to match text - Allocate Licenses");
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Distribute Books')]")).isDisplayed(),
            "Unable to match text - Distribute Books");

    //2.Click Manage Books to Collapse
    driver.findElement(By.className("hd")).click();
    driver.findElement(By.xpath("//a[contains(.,'Manage Books')]")).click();
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(
            By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(3)")));
    //Verify Collapse
    if (driver.findElement(By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(3)"))
            .isDisplayed()) {
        System.out.println("MANAGE BOOKs is collapsed");
    } else {
        System.out.println("MANAGE BOOKS is not collapsed");
    }

    //3.Click Kno Administrative to Collapse
    Assert.assertTrue(
            driver.findElement(By.xpath("//a[contains(.,'Set up Institution Identifier')]")).isDisplayed(),
            "Unable to find text - Set up Institution Identifier");
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'License Code Management')]")).isDisplayed(),
            "Unable to find text - License Code Management");
    driver.findElement(By.className("hd")).click();
    driver.findElement(By.xpath("//a[contains(.,'Kno Administrative')]")).click();
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(
            By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(5)")));
    //Verify Collapse
    if (!(driver.findElement(By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(5)"))
            .isDisplayed())) {
        System.out.println("KNO ADMINISTRATIVE is collapsed");
    } else {
        System.out.println("KNO ADMINISTRATIVE is not collapsed");
    }

    //4.Click Manage Users or Groups
    wait.until(ExpectedConditions
            .visibilityOfAllElementsLocatedBy(By.xpath("//a[contains(.,'Manage Users or Groups')]")));
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Add User')]")).isDisplayed(),
            "Unable to find text - Add User");
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Administer User')]")).isDisplayed(),
            "Unable to find text - Administer User");
    driver.findElement(By.className("hd")).click();
    driver.findElement(By.xpath("//a[contains(.,'Manage Users or Groups')]")).click();
    //Verify Collapse
    if (driver.findElement(By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(2)"))
            .isDisplayed()) {
        System.out.println("Manage Users or Groups is collapsed");
    } else {
        System.out.println("Manage Users or Groups is not collapsed");
    }

    //5.Click Setup
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//a[contains(.,'Setup')]")));
    Assert.assertTrue(
            driver.findElement(By.xpath("//a[contains(.,'Import Devices Configuration')]")).isDisplayed(),
            "Unable to find text - Import Devices Configuration");
    Assert.assertTrue(driver.findElement(By.xpath("//a[contains(.,'Admin Settings')]")).isDisplayed(),
            "Unable to find text - Admin Settings");
    driver.findElement(By.className("hd")).click();
    driver.findElement(By.xpath("//a[contains(.,'Setup')]")).click();
    //Verify Collapse
    if (driver.findElement(By.cssSelector(".scrollable ul li.section.collapse-menu:nth-child(4)"))
            .isDisplayed()) {
        System.out.println("Setup is collapsed");
    } else {
        System.out.println("Setup is not collapsed");
    }

    driver.findElement(By.className("hd")).click();
    driver.findElement(By.className("user-name")).click();
    driver.findElement(By.linkText("Log Out")).click();
    log("Verify Login Text");
    String login_text = driver.findElement(By.cssSelector("#login-form>hgroup>h3")).getText();
    Assert.assertTrue(login_text.equals("Login"), "Unable to find text - Login");
}

From source file:tamil.selenium.maven.Basicactioncmds.java

@Test
public void AdminUser() {
    //Maximize Window
    driver.manage().window().maximize();
    //Goto Advance.kno.com
    driver.get("https://advance.kno.com");
    System.out.println(driver.getCurrentUrl());

    //Login /*  w  ww .  j a  v a 2  s.c om*/
    driver.findElement(By.id("email")).sendKeys("tamil");
    driver.findElement(By.id("password")).sendKeys("123456");
    //driver.findElement(By.linkText("Sign In")).click();
    driver.findElement(By.cssSelector("div[class='field btn-container'] > a")).click();
    WebDriverWait wait = new WebDriverWait(driver, 40);
    wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.className("user-name")));

}

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

License:Open Source License

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

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

License:Open Source License

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

From source file:test.util.Helpers.java

License:Apache License

/**
 * Wait 60 seconds for locator to find all elements
 *//*from   w w w. ja  v a2s .c om*/
public static List<WebElement> waitAll(By locator) {
    return driverWait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(locator));
}