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

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

Introduction

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

Prototype

public static ExpectedCondition<WebElement> elementToBeClickable(final WebElement element) 

Source Link

Document

An expectation for checking an element is visible and enabled such that you can click it.

Usage

From source file:frontend.FrontendLoginTest.java

@Test(description = "wfp frontend setup", priority = 1)
public void frontendSetup() {
    driver.navigate().to("http://localhost:8084/forms");
    WebDriverWait wait = new WebDriverWait(driver, 40);
    WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("username")));
}

From source file:ibw.updater.selenium.SeleniumTestCase.java

License:Open Source License

public WebElement waitAndClick(By by) {
    WebDriverWait wait = new WebDriverWait(driver, MAX_WAIT_TIME);
    if (wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfElementLocated(by),
            ExpectedConditions.elementToBeClickable(by), webDriver -> isReady(webDriver)))) {
        WebElement elm = driver.findElement(by);
        elm.click();// ww w. j a  v a 2 s. c o m
        return elm;
    }

    return null;
}

From source file:ibw.updater.selenium.SeleniumTestCase.java

License:Open Source License

public WebElement waitAndSelectByValue(By by, String value) {
    WebDriverWait wait = new WebDriverWait(driver, MAX_WAIT_TIME);
    if (wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfElementLocated(by),
            ExpectedConditions.elementToBeClickable(by), webDriver -> isReady(webDriver)))) {
        WebElement elm = driver.findElement(by);
        new Select(elm).selectByValue(value);
        return elm;
    }//from  www  . j av  a 2  s  . co  m

    return null;
}

From source file:ibw.updater.selenium.SeleniumTestCase.java

License:Open Source License

public WebElement waitAndSelectByIndex(By by, int index) {
    WebDriverWait wait = new WebDriverWait(driver, MAX_WAIT_TIME);
    if (wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfElementLocated(by),
            ExpectedConditions.elementToBeClickable(by), webDriver -> isReady(webDriver)))) {
        WebElement elm = driver.findElement(by);
        new Select(elm).selectByIndex(index);
        return elm;
    }//from w w  w .  j  a  va 2 s .  c  om

    return null;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive click(By by) {
    waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
            .waitForCondition(ExpectedConditions.elementToBeClickable(by));
    waitForElement(by).click();//from   ww  w .ja v  a 2 s  .  co  m
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive setText(By by, String text) {
    waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
            .waitForCondition(ExpectedConditions.elementToBeClickable(by));
    WebElement element = waitForElement(by);
    element.clear();//from w ww  .  jav  a 2 s . c  o m
    element.sendKeys(text);
    waitForCondition(ExpectedConditions.or(ExpectedConditions.textToBe(by, text),
            ExpectedConditions.attributeToBe(by, "value", text)));
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive check(By by) {
    if (!isChecked(by)) {
        waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
                .waitForCondition(ExpectedConditions.elementToBeClickable(by));
        waitForElement(by).click();//from  w w w  . ja v a 2 s  . com
        assertTrue(by.toString() + " did not check!", isChecked(by));
    }
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive uncheck(By by) {
    if (isChecked(by)) {
        waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
                .waitForCondition(ExpectedConditions.elementToBeClickable(by));
        waitForElement(by).click();/*ww w.  j av a  2s . c o m*/
        assertFalse(by.toString() + " did not uncheck!", isChecked(by));
    }
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive selectOptionByText(By by, String text) {
    Select box = new Select(waitForElement(by));
    waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
            .waitForCondition(ExpectedConditions.elementToBeClickable(by));
    box.selectByVisibleText(text);/*w ww.java2  s . c  om*/
    return this;
}

From source file:io.ddavison.conductor.Locomotive.java

License:Open Source License

public Locomotive selectOptionByValue(By by, String value) {
    Select box = new Select(waitForElement(by));
    waitForCondition(ExpectedConditions.not(ExpectedConditions.invisibilityOfElementLocated(by)))
            .waitForCondition(ExpectedConditions.elementToBeClickable(by));
    box.selectByValue(value);//w  w w  .j  a  v a  2s .  c  o m
    return this;
}