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.fullteaching.backend.e2e.FullTeachingTestE2E.java

License:Apache License

private void logut(BrowserUser user) {
    if (user.getDriver().findElements(By.cssSelector("#fixed-icon")).size() > 0) {
        // Get out of video session page
        user.getDriver().findElement(By.cssSelector("#fixed-icon")).click();
        watiForAngularAnimations(500);//from w w  w . j ava  2s . c  o m
        user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#exit-icon")));
        user.getDriver().findElement(By.cssSelector("#exit-icon")).click();
    }
    //if (user.getDriver().findElements(By.cssSelector("#arrow-drop-down")).size() > 0) {
    try {
        // Up bar menu
        user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS)
                .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#arrow-drop-down")));
        user.getDriver().findElement(By.cssSelector("#arrow-drop-down")).click();
        watiForAngularAnimations(250);
        user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#logout-button")));
        user.getDriver().findElement(By.cssSelector("#logout-button")).click();
    } catch (TimeoutException e) {
        // Shrunk menu
        user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS)
                .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a.button-collapse")));
        user.getDriver().findElement(By.cssSelector("a.button-collapse")).click();
        watiForAngularAnimations(250);
        user.getWaiter().until(ExpectedConditions
                .elementToBeClickable(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")));
        user.getDriver().findElement(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")).click();
    }
    user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("download-button")));
}

From source file:com.fullteaching.backend.e2e.FullTeachingTestE2ESleep.java

License:Apache License

private void logut(BrowserUser user) {
    if (user.getDriver().findElements(By.cssSelector("#fixed-icon")).size() > 0) {
        // Get out of video session page
        user.getDriver().findElement(By.cssSelector("#fixed-icon")).click();
        watiForAngularAnimations(500);//from   w  w  w . ja  v  a 2 s  .com
        user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#exit-icon")));
        user.getDriver().findElement(By.cssSelector("#exit-icon")).click();
    }
    //if (user.getDriver().findElements(By.cssSelector("#arrow-drop-down")).size() > 0) {
    try {
        // Up bar menu
        user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS)
                .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("#arrow-drop-down")));
        user.getDriver().findElement(By.cssSelector("#arrow-drop-down")).click();
        watiForAngularAnimations(250);
        user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.cssSelector("#logout-button")));
        user.getDriver().findElement(By.cssSelector("#logout-button")).click();
    } catch (TimeoutException e) {
        // Shrunk menu
        user.getWaiter().withTimeout(1000, TimeUnit.MILLISECONDS)
                .until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector("a.button-collapse")));
        user.getDriver().findElement(By.cssSelector("a.button-collapse")).click();
        watiForAngularAnimations(250);
        user.getWaiter().until(ExpectedConditions
                .elementToBeClickable(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")));
        user.getDriver().findElement(By.xpath("//ul[@id='nav-mobile']//a[text() = 'Logout']")).click();
    }
    try {
        Thread.sleep(1000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    user.getWaiter().until(ExpectedConditions.elementToBeClickable(By.id("download-button")));
}

From source file:com.ggasoftware.uitest.control.Element.java

License:Open Source License

/**
 * Wait until element is displayed.//from   w w w . j  a v  a 2  s .  co  m
 *
 * @param timeoutSec     seconds to wait until element is displayed.
 * @param checkCondition log assert for expected conditions.
 * @return Parent instance
 */
private ParentPanel waitForDisplayed(int timeoutSec, boolean checkCondition) {
    boolean isDisplayed;
    logAction(this, getParentClassName(), format("waitForDisplayed: %s", locator));
    long start = System.currentTimeMillis() / 1000;
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec)
            .ignoring(StaleElementReferenceException.class);
    setTimeout(1);
    try {
        wait.until(ExpectedConditions.visibilityOfElementLocated(avatar.byLocator));
        isDisplayed = true;
    } catch (TimeoutException e) {
        logTechnical(format("waitForDisplayed: [ %s ] during: [ %d ] sec ", locator,
                System.currentTimeMillis() / 1000 - start));
        isDisplayed = false;
    }
    setTimeout(TIMEOUT);
    if (checkCondition) {
        logAssertTrue(BUSINESS_LEVEL, isDisplayed,
                format("waitForDisplayed - '%s' should be displayed", getName()), takePassedScreenshot);
    }
    return parent;
}

From source file:com.ggasoftware.uitest.control.Elements.java

License:Open Source License

/**
 * Wait until first element is visible.//from  w ww . j a v  a 2  s . co  m
 *
 * @param timeoutSec     seconds to wait until element become visible
 * @param checkCondition log assert for expected conditions.
 * @return Parent instance
 */
public ParentPanel waitForFirstVisibleElement(final int timeoutSec, final boolean checkCondition) {
    logAction(this, getParentClassName(), format("waitForFirstVisibleElement: %s", locator));
    boolean isVisible;
    long start = System.currentTimeMillis() / 1000;
    WebDriverWait wait = (WebDriverWait) new WebDriverWait(getDriver(), timeoutSec)
            .ignoring(StaleElementReferenceException.class);
    setTimeout(1);
    try {
        wait.until(ExpectedConditions.visibilityOfElementLocated(bylocator));
        isVisible = true;
    } catch (TimeoutException e) {
        logTechnical(format("waitForFirstVisibleElement: [ %s ] during: [ %d ] sec ", locator,
                System.currentTimeMillis() / 1000 - start));
        isVisible = false;
    }
    setTimeout(TIMEOUT);
    if (checkCondition) {
        ReporterNGExt.logAssertTrue(ReporterNGExt.BUSINESS_LEVEL, isVisible,
                format("waitForFirstVisibleElement - first element of '%s' should be visible", name),
                TestBaseWebDriver.takePassedScreenshot);
    }
    return parent;
}

From source file:com.github.seleniumpm.SeleniumWebdriver.java

License:Apache License

public Selenium waitForVisible(Object by, long waitTime) {
    WebDriverWait wait = new WebDriverWait(driver, waitTime);
    wait.until(ExpectedConditions.visibilityOfElementLocated((By) by));
    return this;
}

From source file:com.github.seleniumpm.webelements.Element.java

License:Apache License

public Element waitForVisible(long waitTime) {
    WebDriverWait wait = new WebDriverWait(driver, waitTime);
    wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
    return this;
}

From source file:com.googlesites.LoginPage.java

public Sites clickNext() {

    Sites sites = new Sites(driver);
    if (driver.findElement(By.id("next")) != null) {

        driver.findElement(By.id("next")).click();
        driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("Passwd")));

    }/*from  w  w w .j  ava2  s.  c  o m*/
    return sites;
}

From source file:com.googlesites.Site.java

public void clickOnButton(String buttonLabel) {

    driver.findElement(By.id(SAVE_CANCEL_BUTTONS.replace("@buttonName@", buttonLabel.toLowerCase()))).click();
    if (buttonLabel.equals("Save")) {

        WebDriverWait wait = new WebDriverWait(driver, 5);
        wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(SITE_NOTICE)));
    }// w  w w  .  j ava  2 s . c  om
    driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}

From source file:com.hotwire.selenium.bex.BexAbstractPage.java

License:Open Source License

protected WebElement findOne(By seleniumByObject, int timeInSeconds) {
    return new WebDriverWait(getWebDriver(), timeInSeconds)
            .until(ExpectedConditions.visibilityOfElementLocated(seleniumByObject));
}

From source file:com.hotwire.selenium.bex.BexAbstractPage.java

License:Open Source License

/**
 * Use it if select on webpage is invisible and decorated by links
 * @param selectLinkCss  - visible selector link
 * @param linkText   - text of the link in selector
 *//*from w  w  w  .  j  a va2 s. c  om*/
protected void selectLink(String selectLinkCss, String linkText) {
    getWebDriver().findElement(By.cssSelector(selectLinkCss)).click();
    new WebDriverWait(getWebDriver(), DEFAULT_WAIT)
            .until(ExpectedConditions.visibilityOfElementLocated(By.linkText(linkText))).click();
}