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

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

Introduction

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

Prototype

public static ExpectedCondition<WebElement> presenceOfElementLocated(final By locator) 

Source Link

Document

An expectation for checking that an element is present on the DOM of a page.

Usage

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Checks if is selected./*from w w w  .jav  a2s  .com*/
 * 
 * @param driver the driver
 * @param locator the locator
 * @param timeout the timeout
 * @return true, if is selected
 */
public static boolean isSelected(final WebDriver driver, final By locator, final Timeout timeout) {

    try {
        return new WebDriverWait(driver, timeout.getValue())
                .until(ExpectedConditions.presenceOfElementLocated(locator)).isSelected();
    } catch (Exception ex) {
        return false;
    }
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Gets the element./*from  w  w  w  .  ja  v a 2s.c  o m*/
 * 
 * @param driver the driver
 * @param locator the locator
 * @param timeout the timeout
 * @return the element
 */
public static WebElement getElement(final WebDriver driver, final By locator, final Timeout timeout) {

    try {
        return new WebDriverWait(driver, timeout.getValue())
                .until(ExpectedConditions.presenceOfElementLocated(locator));
    } catch (Exception ex) {
        return null;
    }
}

From source file:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

/**
 * Gets the element.//  w w w  .j a  v  a  2  s . co  m
 * 
 * @param driver the driver
 * @param attributeName the attribute name
 * @param attributeValue the attribute value
 * @param timeout the timeout
 * @return the element
 */
public static WebElement getElement(final WebDriver driver, final String attributeName,
        final String attributeValue, final Timeout timeout) {

    try {
        return new WebDriverWait(driver, timeout.getValue())
                .until(ExpectedConditions.presenceOfElementLocated(attribute(attributeName, attributeValue)));
    } catch (Exception ex) {
        return null;
    }
}

From source file:com.cognifide.aet.job.common.SeleniumWaitHelper.java

License:Apache License

public static void waitForElementToBePresent(WebDriver webDriver, By elementLocator, long timeOut)
        throws WebDriverException {
    WebDriverWait wait = new WebDriverWait(webDriver, timeOut);
    wait.until(ExpectedConditions.presenceOfElementLocated(elementLocator));
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem62.NavigatorDropdown.java

License:Apache License

public void selectByPath(String path) {
    wait.withTimeout(Timeouts.SMALL)/*from  w ww  .j  av  a2 s . c o  m*/
            .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(DROPDOWN_ITEMS_SELECTOR)));
    revealNavigatorDropdownBtn.click();
    getDropdownOptions().stream().filter(webElement -> webElement.getAttribute(PATH_ATTR).equals(path))
            .findFirst().get().click();
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem62.NavigatorDropdown.java

License:Apache License

public void selectByTitle(String title) {
    wait.withTimeout(Timeouts.SMALL)//w w  w.  ja v a  2s .  c om
            .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(DROPDOWN_ITEMS_SELECTOR)));
    revealNavigatorDropdownBtn.click();
    getDropdownOptions().stream().filter(webElement -> webElement.getText().equals(title)).findFirst().get()
            .click();
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem62.NavigatorDropdown.java

License:Apache License

public List<String> getAvailablePaths() {
    wait.withTimeout(Timeouts.SMALL)/*  w w  w  . j  a v  a  2s .co m*/
            .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(DROPDOWN_ITEMS_SELECTOR)));
    return getDropdownOptions().stream().map(webElement -> webElement.getAttribute(PATH_ATTR))
            .collect(Collectors.toList());
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem62.NavigatorDropdown.java

License:Apache License

public List<String> getAvailableTitles() {
    wait.withTimeout(Timeouts.SMALL)//from  w  w w  .ja v a 2  s .com
            .until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(DROPDOWN_ITEMS_SELECTOR)));
    return getDropdownOptions().stream()
            .map(webElement -> webElement.getAttribute(HtmlTags.Properties.INNER_HTML))
            .collect(Collectors.toList());
}

From source file:com.cognifide.qa.bb.aem.ui.messages.AemBubbleMessage.java

License:Apache License

/**
 * Waits for presence of notification message in author mode
 *
 * @return This AemBubbleMessage instance
 *///w  w  w  .j  a  v  a2 s  . com
public AemBubbleMessage waitForAemBubbleMessage() {
    bobcatWait.withTimeout(Timeouts.MEDIUM)
            .until(ExpectedConditions.presenceOfElementLocated(BUBBLE_MSG_BY_SELECTOR));
    return this;
}

From source file:com.comcast.dawg.house.AdvanceFilterUIIT.java

License:Apache License

private void performSearchAndCheckDevices(RemoteWebDriver driver, String[] deviceIdsToHave,
        String[] deviceIdsNotToHave) {
    WebElement filteredTable = driver.findElementByClassName(IndexPage.FILTERED_TABLE);

    WebDriverWait wait = new WebDriverWait(driver, 20);
    driver.findElementByClassName(IndexPage.BTN_SEARCH).click();

    /** Need two waits... first for the original table to be removed from the DOM, then for it
     * to be present again *//* ww  w .j a v  a 2 s .  c  o m*/
    wait.until(ExpectedConditions.stalenessOf(filteredTable));
    wait.until(ExpectedConditions.presenceOfElementLocated(By.className(IndexPage.FILTERED_TABLE)));
    filteredTable = driver.findElementByClassName(IndexPage.FILTERED_TABLE);

    if (deviceIdsToHave != null) {
        hasDevices(filteredTable, deviceIdsToHave, true);
    }
    if (deviceIdsNotToHave != null) {
        hasDevices(filteredTable, deviceIdsNotToHave, false);
    }
}