Example usage for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

List of usage examples for org.openqa.selenium.support.ui WebDriverWait WebDriverWait

Introduction

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

Prototype

public WebDriverWait(WebDriver driver, Duration timeout) 

Source Link

Document

Wait will ignore instances of NotFoundException that are encountered (thrown) by default in the 'until' condition, and immediately propagate all others.

Usage

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Utility to check weather the particular field is displayed or not.
 * @param driver the driver/*from   w ww .  j  a v  a 2s  .  c om*/
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isNotDisplayedById(final WebDriver driver, final String fieldname, int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut))
            .until(ExpectedConditions.invisibilityOfElementLocated(By.id(fieldname)));

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Is particular element displayed by class Name. . .
 * @param driver the driver//from  ww  w.ja  v a2  s .  c  o m
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isDisplayedByClassName(final WebDriver driver, final String fieldname,
        final int timeOut) {

    boolean isLoaded = false;
    try {
        isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                return d.findElement(By.className(fieldname)).isDisplayed();
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }
    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Checks if is displayed by xpath./*w w  w .  j a v a 2 s  .  c om*/
 *
 * @param driver the driver
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return true, if is displayed by xpath
 */
public static boolean isDisplayedByXpath(final WebDriver driver, final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    try {
        isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                return d.findElement(By.xpath(fieldname)).isDisplayed();
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }
    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Is elements displayed by class Name. . .
 * @param driver the driver/* www .ja v  a2s . c om*/
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isMultipleClassNameDisplayed(final WebDriver driver, final String fieldname,
        final int timeOut) {

    boolean isLoaded = false;
    try {
        isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                List<WebElement> scheduleChartElmtList = driver.findElements(By.className(fieldname));
                if (scheduleChartElmtList.size() > 0) {

                    return true;
                }
                return false;
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Multiple elements displayed by Tag Name.
 * @param driver the driver/*from  ww w.  j a v  a 2 s. c o  m*/
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isMultipleTagNameDisplayed(final WebDriver driver, final String fieldname,
        final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            List<WebElement> elmtList = driver.findElements(By.tagName(fieldname));
            boolean returnValue = false;
            returnValue = elmtList != null && elmtList.size() > 0 ? true : false;
            return returnValue;
        }
    });

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Is elements displayed by Tag Name. . .
 * @param driver the driver/*from ww w . jav  a2  s  .com*/
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isElementTagNameDisplayed(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            List<WebElement> elmtList = element.findElements(By.tagName(fieldname));
            if (elmtList.size() > 0) {
                return true;
            }
            return false;
        }
    });

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Is form elements Id displayed by Tag Name. . .
 * @param driver the driver//w  w w.j av a  2  s  .  co m
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isElementIdDisplayed(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            List<WebElement> elmtList = element.findElements(By.id(fieldname));
            if (elmtList.size() > 0) {
                return true;
            }
            return false;
        }
    });

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Is elements displayed by Tag Name. . .
 * @param driver the driver/*from  w w  w .  j  ava2s.  c  o m*/
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return boolean
 */
public static boolean isFormDisplayedById(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            if (element.findElement(By.id(fieldname)).isDisplayed()) {
                return true;
            }
            return false;

        }
    });

    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Checks if is element exists by id./*w w  w  . j  a  v a2s .  com*/
 * @param driver the driver
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return true, if is element exists by id
 */
public static boolean isElementExistsById(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    try {
        isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
            public Boolean apply(WebDriver d) {

                WebElement element1 = element.findElement(By.id(fieldname));
                return element1.isDisplayed();
            }
        });
    } catch (TimeoutException te) {
        isLoaded = false;
    }
    return isLoaded;
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Checks if is form displayed by class name.
 * @param driver the driver/*  ww w . j  av a2s .  com*/
 * @param element the element
 * @param fieldname the fieldname
 * @param timeOut the time out
 * @return true, if is form displayed by class name
 */
public static boolean isFormDisplayedByClassName(final WebDriver driver, final WebElement element,
        final String fieldname, final int timeOut) {

    boolean isLoaded = false;
    isLoaded = (new WebDriverWait(driver, timeOut)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {

            if (element.findElement(By.className(fieldname)).isDisplayed()) {
                return true;
            }
            return false;

        }
    });

    return isLoaded;
}