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:org.xwiki.application.webide.test.po.ProjectPage.java

public void goToClass(String space, String page) throws InterruptedException {
    this.openCategory("classes");
    this.openClass(space, page);
    WebElement wec = getDriver().findElement(
            By.cssSelector(".editAWM[data-page=\"" + page + "Class\"][data-space=\"" + space + "\"]"));
    new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wec));
    wec.click();//w  ww  .  ja  v  a 2 s  .  c  o  m
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

private void openCategory(String category) {
    WebElement wec = getDriver()/*from  w ww  .j a v  a  2s .com*/
            .findElement(By.cssSelector(".hierarchy-toggleCategory[data-category=\"" + category + "\"]"));
    WebElement wecContent = getDriver().findElement(By.id("hierarchyCategory_" + category));
    while (!wecContent.isDisplayed()) {
        new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wec));
        wec.click();
    }
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

private void openSpace(String space) {
    WebElement wes = getDriver()//from w w  w  . j av  a2  s  .  c  om
            .findElement(By.cssSelector(".hierarchy-toggleFolder[data-space=\"" + space + "\"]"));
    WebElement wesContent = getDriver().findElement(By.id("hierarchySpace_" + space));
    while (!wesContent.isDisplayed()) {
        new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wes));
        wes.click();
    }
}

From source file:org.xwiki.application.webide.test.po.ProjectPage.java

private void openClass(String space, String name) {
    WebElement wes = getDriver().findElement(By.id("hierarchyDisplayPage_" + space + "." + name + "Class"));
    WebElement wesContent = getDriver()//from   ww  w .  java  2 s  . c  o m
            .findElement(By.id("hierarchyPageDetails_Class-" + space + "." + name + "Class"));
    while (!wesContent.isDisplayed()) {
        new WebDriverWait(getDriver(), 10).until(ExpectedConditions.elementToBeClickable(wes));
        wes.click();
    }
}

From source file:org.zanata.page.AbstractPage.java

License:Open Source License

/**
 * Convenience function for clicking elements.  Removes obstructing
 * elements, scrolls the item into view and clicks it when it is ready.
 * @param element element to be clicked// w  ww .  j a v a 2s  .  co  m
 */
public void clickElement(final WebElement element) {
    removeNotifications();
    waitForNotificationsGone();
    scrollIntoView(element);
    waitForAMoment().withMessage("clickable: " + element.toString())
            .until(ExpectedConditions.elementToBeClickable(element));
    element.click();
}

From source file:org.zanata.page.AbstractPage.java

License:Open Source License

/**
 * Enter text into an element./* w ww  . java2  s  .  co  m*/
 *
 * Waits for notifications to be dismissed and element to be ready and visible before entering
 * the text.
 * If no checking is performed, the resulting screenshot may not be accurate.
 * @param element element to pass text to
 * @param text text to be entered
 * @param clear clear the element's text before entering new text
 * @param inject use sendKeys rather than the Actions chain (direct injection)
 * @param check check the 'value' attribute for success, and accurate screenshot delay
 */
public void enterText(final WebElement element, final String text, boolean clear, boolean inject,
        final boolean check) {
    removeNotifications();
    waitForNotificationsGone();
    scrollIntoView(element);
    triggerScreenshot("_pretext");
    waitForAMoment().withMessage("editable: " + element.toString())
            .until(ExpectedConditions.elementToBeClickable(element));
    if (inject) {
        if (clear) {
            element.clear();
        }
        element.sendKeys(text);
    } else {
        Actions enterTextAction = new Actions(getDriver()).moveToElement(element);
        enterTextAction = enterTextAction.click();
        // Fields can 'blur' on click
        waitForPageSilence();
        if (clear) {
            enterTextAction = enterTextAction.sendKeys(Keys.chord(Keys.CONTROL, "a")).sendKeys(Keys.DELETE);
            // Fields can 'blur' on clear
            waitForPageSilence();
        }
        enterTextAction.sendKeys(text).perform();
    }
    if (check) {
        waitForAMoment().withMessage("Text equal to entered").until((Predicate<WebDriver>) webDriver -> {
            String foundText = element.getAttribute("value");
            if (!text.equals(foundText)) {
                log.info("Found: {}", foundText);
                triggerScreenshot("_textWaiting");
                return false;
            }
            return true;
        });
    } else {
        log.info("Not checking text entered");
    }
    triggerScreenshot("_text");
}

From source file:PageObjects.Mst_EditLengthPage.java

public Mst_AddLengthPage setLengthName(String item) {
    WebElement element = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(lengthNameField));
    element.clear();/*www .ja  v  a  2s  .  com*/

    CommonTask.setInputField(driver, lengthNameField, item);
    return new Mst_AddLengthPage(driver);
}

From source file:PageObjects.Mst_EditLengthPage.java

public Mst_LengthsPage pressSave() {
    WebElement element = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(saveButton));
    element.click();// w ww  .j a  v  a2 s.c o m

    return new Mst_LengthsPage(driver);
}

From source file:PageObjects.Mst_EditLengthPage.java

public void checkFields() {
    WebElement lengthName = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(lengthNameField));
    WebElement save = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(saveButton));
    WebElement cancel = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(cancelButton));

    AssertJUnit.assertTrue("Add Length Page: Length Name field not displayed", lengthName.isDisplayed());
    AssertJUnit.assertTrue("Add Length Page: Save button not displayed", save.isDisplayed());
    AssertJUnit.assertTrue("Add Length Page: Cancel button not displayed", cancel.isDisplayed());
}

From source file:PageObjects.Mst_EditLengthPage.java

public void waitForElement() {
    WebElement lengthName = new WebDriverWait(driver, DataItems.shortWait)
            .until(ExpectedConditions.elementToBeClickable(lengthNameField));
}