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.daarons.transfer.UploadTask.java

License:Apache License

private void clickEmailButton() {
    WebElement emailButton = smallWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer > div > div.scrollable.transfer__contents.scrollable--overflow-top > div.scrollable__content > div.transfer__options > div.transfer__option > div > svg > path")));
    String transform = getTransformAttribute(emailButton);
    if (!transform.equals("translate(0, 0)")) {
        emailButton.click();/*from w w  w.  ja v  a 2s  .  c  o m*/
    }
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void inputMessage(Message message) {
    WebElement toInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__autosuggest > input")));
    toInput.clear();//  w  w w.  ja  v  a2 s  . com
    toInput.sendKeys(message.getTo());
    WebElement fromInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > input")));
    fromInput.clear();
    fromInput.sendKeys(message.getFrom());
    WebElement messageInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__fields > div.uploader__message > textarea")));
    messageInput.clear();
    messageInput.sendKeys(message.getMessage());
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void clickLinkButton() {
    WebElement linkButton = smallWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer > div > div.scrollable.transfer__contents.scrollable--overflow-top > div.scrollable__content > div.transfer__options > div.transfer__option > div > svg > path")));
    String transform = getTransformAttribute(linkButton);
    if (transform.equals("translate(0, 0)")) {
        linkButton.click();/*w ww .  ja  v  a2s . c  o m*/
    }
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void enterUploadPassword(String transferPassword) {
    WebElement transferPasswordInput = longWait
            .until(ExpectedConditions.presenceOfElementLocated(By.id("transfer__password")));
    transferPasswordInput.sendKeys(transferPassword);
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void inputFilePath(String filePath) {
    WebElement fileInput = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.scrollable.transfer__contents > div.scrollable__content > div.uploader__files > form > input[type=\"file\"]")));
    fileInput.sendKeys(filePath);//  w w w .  ja v a 2s.  c om
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private int getUploadTime(WebDriverWait wait) {
    WebElement timeLeftElement = wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > div.transfer.transfer--half-panel > div > div.transfer__contents > p:nth-child(4)")));

    // then get the text in the time_left element & calculate the time to upload
    String timeLeft = timeLeftElement.getText();
    int until;/*  w ww  .  j  a  v  a2  s. c  om*/
    if (timeLeft.matches("(.*)hour(.*)") || timeLeft.matches("(.*)hours(.*)")) { //hours
        timeLeft = timeLeft.replaceAll("\\D+", "");
        if (timeLeft.isEmpty()) {
            until = 60;
        } else {
            until = new Integer(timeLeft) * 60;
        }
    } else if (timeLeft.matches("(.*)under a minute(.*)")) { // < 1min
        until = 1;
    } else { //everything else but mostly 'minutes'
        timeLeft = timeLeft.replaceAll("\\D+", "");
        try {
            until = new Integer(timeLeft);
        } catch (NumberFormatException ex) {
            log.error("The upload time did not contains integers", ex);
            until = 1;
        }
    }
    return until;
}

From source file:com.daarons.transfer.UploadTask.java

License:Apache License

private void logOut() {
    WebElement accountLink = longWait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector(
            "body > div > div > nav > ul > li.nav__item.nav_item--expanded.nav__item--active > ul > li:nth-child(4) > a")));
    accountLink.click();/*w  w w  .ja v a  2  s. c  om*/
    WebElement signOutButton = longWait
            .until(ExpectedConditions.presenceOfElementLocated(By.className("account__signout")));
    signOutButton.click();
}

From source file:com.elastica.webelements.BasePage.java

License:Apache License

public void waitForElementPresent(final By by) {
    TestLogging.logWebStep(null, "wait for " + by.toString() + " to be present.", false);

    WebDriverWait wait = new WebDriverWait(driver, explictWaitTimeout);
    wait.until(ExpectedConditions.presenceOfElementLocated(by));
}

From source file:com.elastica.webelements.BasePage.java

License:Apache License

public void waitForElementPresent(final By by, final int timeout) {
    TestLogging.logWebStep(null, "wait for " + by.toString() + " to be present.", false);

    WebDriverWait wait = new WebDriverWait(driver, timeout);
    wait.until(ExpectedConditions.presenceOfElementLocated(by));
}

From source file:com.elastica.webelements.BasePage.java

License:Apache License

public void waitForElementPresent(final HtmlElement element) {
    Assert.assertNotNull(element, "Element can't be null");
    TestLogging.logWebStep(null, "wait for " + element.toString() + " to be present.", false);

    WebDriverWait wait = new WebDriverWait(driver, explictWaitTimeout);
    wait.until(ExpectedConditions.presenceOfElementLocated(element.getBy()));
}