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

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

Introduction

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

Prototype

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

Source Link

Document

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

Usage

From source file:com.cengage.mindtap.keywords.BasePageActions.java

public void waitForDomToLoad() {
    WebDriverWait wait = new WebDriverWait(driver, 80);
    wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*")));
}

From source file:com.cengage.mtx.keywords.MTXGradebookScoreVerificationPageAction.java

public WebElement getWhenVisible(By locator, int timeout) {
    WebElement element;//from   w ww  .  j a  v a 2 s .  c o  m
    WebDriverWait wait = new WebDriverWait(driver, timeout);
    element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
    return element;
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public boolean isVisible(final String locator) {
    try {//from   ww  w . j av  a  2 s.  c o  m
        (new WebDriverWait(webDriver, 1))
                .until(ExpectedConditions.visibilityOfElementLocated(getSelector(locator)));
        return true;
    } catch (Exception e1) {
        return false;
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

/**
 * Determines if the specified element is visible. An element can be rendered invisible by setting the CSS
 * "visibility" property to "hidden", or the "display" property to "none", either for the element itself or
 * one if its ancestors. This method will fail if the element is not present.
 *
 * @param locator an <a href="#locators">element locator</a>
 * @param timeout int time value//from   ww w  . j  a v  a2  s. c  o  m
 * @return true if the specified element is visible, false otherwise
 */
@Override
public boolean isElementVisibleWithWait(String locator, int timeout) {
    try {
        (new WebDriverWait(webDriver, timeout))
                .until(ExpectedConditions.visibilityOfElementLocated(getSelector(locator)));
        return true;
    } catch (Exception e1) {
        return false;
    }
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

License:Open Source License

@Override
public void waitForElementVisible(String guiElementDescription, int timeoutInSeconds) {
    String msg = "Wait %ss for [%s] on page [%s]";
    log.debug("waitForElementVisible should time out in " + timeoutInSeconds);
    log.debug(String.format(msg, timeoutInSeconds, guiElementDescription, this.getClass().getSimpleName()));
    WebElement e = (new WebDriverWait(webDriver, timeoutInSeconds))
            .until(ExpectedConditions.visibilityOfElementLocated(getSelector(guiElementDescription)));
    log.debug("Element found");
    if (e != null) {
        return;//from   ww  w  .j a va  2s.  co m
    } else {
        throw new ElementNotVisibleException(guiElementDescription + " did not become visible.");
    }
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method to find visible element./*from   ww  w.  java2  s.  c  o m*/
 *
 * @param by
 *            (by element)
 * @return visibleElement (visible element)
 */
public WebElement findVisibleElement(final By by) {
    WebElement visibleElement;
    try {
        visibleElement = (new WebDriverWait(this.driver, this.DEFAULT_TIMEOUT))
                .until(ExpectedConditions.visibilityOfElementLocated(by));
    } catch (Throwable cause) {
        String errorMessage = "Could not find visible element: " + by.toString();
        this.logger.logWithScreenShot("findVisibleElement failed.", this.driver);
        throw new RuntimeException(errorMessage);
    }
    return visibleElement;
}

From source file:com.citrix.g2w.webdriver.pages.BasePage.java

License:Open Source License

/**
 * Method to find visible element in the page.
 * //  w  w  w. ja  v a2 s. c o m
 * @param by
 *            (by element to be visible in page)
 * @param timeoutInSeconds
 *            (timeout value in seconds)
 * @return visibleElement (Web element object of the visible element)
 */
public WebElement findVisibleElement(final By by, final int timeoutInSeconds) {
    WebElement visibleElement;
    try {
        visibleElement = (new WebDriverWait(this.driver, timeoutInSeconds))
                .until(ExpectedConditions.visibilityOfElementLocated(by));
    } catch (Throwable clause) {
        String errorMessage = "Could not find visible element: " + by.toString();
        this.logger.logWithScreenShot("Could not find visible element: ", this.driver);
        throw new RuntimeException(errorMessage);
    }
    return visibleElement;
}

From source file:com.codenvy.corp.MainPage.java

License:Open Source License

public void gotoMainPageWaitAuthorizePageAndLogin(String login, String passWord) throws InterruptedException {
    driver.get(baseUrl);//from   w w  w  . j a  va  2  s  . c  o m
    new WebDriverWait(driver, 40)
            .until(ExpectedConditions.visibilityOfAllElements(Arrays.asList(loginField, passField)));
    loginField.sendKeys(login);
    passField.sendKeys(passWord);
    loginBtnb.click();
    Thread.sleep(15000);
    new WebDriverWait(driver, 5).until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Agile")))
            .click();
    initId();

}

From source file:com.codenvy.corp.MainPage.java

License:Open Source License

public void gotoManageViewAndGoToIdeBornDown() throws IOException, InterruptedException {
    driver.get(String.format(mangeViewUrlIDE, agileIdIDE));
    new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(burnDownMAinContainer));
    burnDownNameIDE = new WebDriverWait(driver, 10)
            .until(ExpectedConditions.visibilityOfElementLocated(By.id("ghx-items-trigger"))).getText();
    Thread.sleep(10000);/*from  www. j  a va 2s .  co m*/
    File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    Point p = burnDownMAinContainer.getLocation();

    int width = burnDownMAinContainer.getSize().getWidth();
    int height = burnDownMAinContainer.getSize().getHeight();

    BufferedImage img = ImageIO.read(screen);

    BufferedImage dest = img.getSubimage(p.getX(), p.getY() - 50, width, height);

    ImageIO.write(dest, "png", screen);
    File file = new File(burnDownNameIDE + ".png");
    FileUtils.copyFile(screen, file);
    addText(file, burnDownNameIDE);
}

From source file:com.codenvy.corp.MainPage.java

License:Open Source License

public void gotoManageViewAndGrabCLDIDEBornDown() throws IOException, InterruptedException {
    driver.get(String.format(mangeViewUrlCLDIDE, agileIdPLF));
    new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(burnDownMAinContainer));
    burnDownNamePlf = new WebDriverWait(driver, 10)
            .until(ExpectedConditions.visibilityOfElementLocated(By.id("ghx-items-trigger"))).getText();
    Thread.sleep(10000);/* w  w w.  j  a  v a 2s. c  om*/
    File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    Point p = burnDownMAinContainer.getLocation();
    int width = burnDownMAinContainer.getSize().getWidth();
    int height = burnDownMAinContainer.getSize().getHeight();
    BufferedImage img = ImageIO.read(screen);
    BufferedImage dest = img.getSubimage(p.getX(), p.getY() - 50, width, height);
    ImageIO.write(dest, "png", screen);
    File file = new File(burnDownNamePlf + ".png");
    FileUtils.copyFile(screen, file);
    addText(file, burnDownNamePlf);

}