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:org.orcid.integration.blackbox.web.SigninTest.java

License:Open Source License

public static void dismissVerifyEmailModal(WebDriver webDriver) {
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    List<WebElement> weList = webDriver.findElements(By.xpath("//div[@ng-controller='VerifyEmailCtrl']"));
    if (weList.size() > 0) {// we need to wait for the color box to appear
        wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(
                By.xpath("//div[@ng-controller='VerifyEmailCtrl' and @orcid-loading='false']")));
        ((JavascriptExecutor) webDriver).executeScript("$.colorbox.close();");
        colorBoxIsClosed(wait);//from  w  w  w  .  j  av  a  2 s.c  o  m
    }
}

From source file:org.orcid.integration.blackbox.web.works.AddWorksTest.java

License:Open Source License

public static void addSimple(String workName, WebDriver webDriver) {
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    ;/*from w ww  .jav  a 2 s  . co m*/
    waitWorksLoaded(wait);
    // Selenium is having issues finding this element, I supect do to CSS transformations
    // Run the function directly
    ((JavascriptExecutor) webDriver)
            .executeScript("angular.element('[ng-controller=WorkCtrl]').scope().addWorkModal()");

    wait.until(ExpectedConditions
            .presenceOfElementLocated(By.xpath("//select[@ng-model='editWork.workCategory.value']")));
    Select catSel = new Select(
            webDriver.findElement(By.xpath("//select[@ng-model='editWork.workCategory.value']")));
    catSel.selectByVisibleText("Conference");
    wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//option[text()='Conference paper']")));
    Select typeSel = new Select(
            webDriver.findElement(By.xpath("//select[@ng-model='editWork.workType.value']")));
    typeSel.selectByVisibleText("Conference paper");
    WebElement title = webDriver.findElement(By.xpath("//input[@ng-model='editWork.title.value']"));
    title.sendKeys(workName);
    WebElement buttonEl = webDriver.findElement(By.xpath("//button[@id='save-new-work']"));
    buttonEl.click();
    SigninTest.colorBoxIsClosed(wait);
    waitWorksLoaded(wait);
    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName)));
}

From source file:org.orcid.integration.blackbox.web.works.AddWorksTest.java

License:Open Source License

public static void deleteAllByWorkName(String workName, WebDriver webDriver) {
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    waitWorksLoaded(wait);//from   www .ja va 2s .  c  o m
    List<WebElement> wList = webDriver
            .findElements(By.xpath("//*[@orcid-put-code and descendant::span[text() = '" + workName + "']]"));
    if (wList.size() > 0)
        for (WebElement we : wList) {
            String putCode = we.getAttribute("orcid-put-code");
            putCode = "" + putCode;
            String deleteJsStr = "angular.element('*[ng-app]').injector().get('worksSrvc').deleteWork('"
                    + putCode + "');";
            ((JavascriptExecutor) webDriver).executeScript(deleteJsStr);
            waitWorksLoaded(wait);
        }
    wait.until(
            ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(byWorkTitle(workName))));
    assertTrue(0 == webDriver.findElements(byWorkTitle(workName)).size());
}

From source file:org.orcid.integration.blackbox.web.works.AddWorksTest.java

License:Open Source License

public static void waitWorksLoaded(WebDriverWait wait) {
    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(
            By.xpath("//div[@id='workspace-publications' and @orcid-loaded='true']")));
}

From source file:org.orcid.integration.blackbox.web.works.PrivacyWorksTest.java

License:Open Source License

@Test
public void addThreeSimple() {
    WebDriverWait wait = new WebDriverWait(webDriver, 10);
    AddWorksTest.waitWorksLoaded(wait);//from  www  . j  a v  a2s . com
    // clean up any from previous test
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _A, webDriver);
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _B, webDriver);
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _C, webDriver);

    // Test actually begins
    AddWorksTest.addSimple(PRIVACY_WORKS_TEST + _A, webDriver);
    AddWorksTest.addSimple(PRIVACY_WORKS_TEST + _B, webDriver);
    AddWorksTest.addSimple(PRIVACY_WORKS_TEST + _C, webDriver);
    assertEquals(1, webDriver.findElements(AddWorksTest.byWorkTitle(PRIVACY_WORKS_TEST + _A)).size());
    assertEquals(1, webDriver.findElements(AddWorksTest.byWorkTitle(PRIVACY_WORKS_TEST + _B)).size());
    assertEquals(1, webDriver.findElements(AddWorksTest.byWorkTitle(PRIVACY_WORKS_TEST + _C)).size());

    webDriver.findElement(selectPublicByTitle(PRIVACY_WORKS_TEST + _A)).click();
    webDriver.findElement(selectLimitedByTitle(PRIVACY_WORKS_TEST + _B)).click();
    webDriver.findElement(selectPrivateByTitle(PRIVACY_WORKS_TEST + _C)).click();

    AddWorksTest.reloadWorks(webDriver, wait);

    wait.until(ExpectedConditions.presenceOfAllElementsLocatedBy(privIsVis(PRIVACY_WORKS_TEST + _A, "PUBLIC")));
    wait.until(
            ExpectedConditions.presenceOfAllElementsLocatedBy(privIsVis(PRIVACY_WORKS_TEST + _B, "LIMITED")));
    wait.until(
            ExpectedConditions.presenceOfAllElementsLocatedBy(privIsVis(PRIVACY_WORKS_TEST + _C, "PRIVATE")));

    // clean up after test
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _A, webDriver);
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _B, webDriver);
    AddWorksTest.deleteAllByWorkName(PRIVACY_WORKS_TEST + _C, webDriver);
}

From source file:org.testeditor.fixture.web.AbstractWebFixture.java

License:Open Source License

/**
 * Finds and returns all web element in the DOM matching the technical
 * locator. This does not necessarily mean that the elements are visible.
 * The configured {@code timeout} is used to specify the time to wait for
 * the element./*from www .  ja  va2s  . com*/
 * 
 * @param elementListKey
 *            key in the element list to find the technical locator
 * @param replaceArgs
 *            values to replace the place holders in the element list entry
 * @return the web elements or {@code null} if no matching element is
 *         present in the DOM
 * @throws StopTestException
 *             if a timeout occurred while finding the web elements
 */
protected List<WebElement> findWebElements(String elementListKey, String... replaceArgs)
        throws StopTestException {
    int interval = (int) Math.floor(Math.sqrt(timeout));
    Wait<WebDriver> wait = new FluentWait<WebDriver>(webDriver).withTimeout(timeout, TimeUnit.SECONDS)
            .pollingEvery(interval, TimeUnit.SECONDS)
            .ignoring(NoSuchElementException.class, StaleElementReferenceException.class);
    try {
        return wait.until(
                ExpectedConditions.presenceOfAllElementsLocatedBy(createBy(elementListKey, replaceArgs)));
    } catch (TimeoutException e) {
        throw new StopTestException("There was a timeout while finding the element '"
                + createBy(elementListKey, replaceArgs) + "'!");
    }
}

From source file:org.xwiki.contrib.tour.test.po.PageWithTour.java

License:Open Source License

public void previousStep() {
    // Get the current step id
    String stepId = getStepId();/*from   w  w  w.j a v  a2  s  . c o m*/
    // Click
    getDriver().findElement(By.xpath("//button[@data-role='prev']")).click();
    // Wait until current state disappears
    getUtil().waitUntilCondition(
            ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(stepId))));
    // Wait until new step appears
    getUtil().waitUntilCondition(ExpectedConditions.presenceOfElementLocated(By.className("tour")));
}

From source file:org.xwiki.contrib.tour.test.po.PageWithTour.java

License:Open Source License

public void nextStep() {
    // Get the current step id
    String stepId = getStepId();//  w  w  w.ja va2s .c om
    // Click
    getDriver().findElement(By.xpath("//button[@data-role='next']")).click();
    // Wait until current state disappears
    getUtil().waitUntilCondition(
            ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(By.id(stepId))));
    // Wait until new step appear
    getUtil().waitUntilCondition(ExpectedConditions.presenceOfElementLocated(By.className("tour")));
}

From source file:org.xwiki.contrib.tour.test.po.PageWithTour.java

License:Open Source License

public void end() {
    getDriver().findElement(By.xpath("//div[contains(@class, 'popover-navigation')]//button[@data-role='end']"))
            .click();/*w  w  w  .  j a  va 2s.  c o  m*/
    getUtil().waitUntilCondition(
            ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("tour"))));
}

From source file:org.xwiki.contrib.tour.test.po.PageWithTour.java

License:Open Source License

public void close() {
    getDriver().findElement(By.xpath("//button[@data-role='end' and contains(@class, 'btn-default')]")).click();
    getUtil().waitUntilCondition(/*from   ww w  .ja  va2 s  . co m*/
            ExpectedConditions.not(ExpectedConditions.presenceOfAllElementsLocatedBy(By.className("tour"))));
}