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:com.coderoad.automation.common.util.PageUtil.java

License:Open Source License

public static boolean isWebElementClickable(final WebDriver driver, final WebElement element,
        final Timeout timeout) {

    try {/*from w  ww .jav a  2 s  .com*/
        return new WebDriverWait(driver, timeout.getValue())
                .until(ExpectedConditions.elementToBeClickable(element)).isDisplayed();
    } catch (Exception te) {
        return false;
    }
}

From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java

License:Open Source License

protected void waitForElementPresence(String element) {

    TestLogger.logMsg("Start waitForElementPresence : + " + this.getTimeStamp());
    for (int i = 0; i < 1; i++) {
        try {//from w ww  .  j a va 2 s  . c o m
            WebElement myDynamicElement = (new WebDriverWait(driver, TestUtils.timeout))
                    .until(ExpectedConditions.elementToBeClickable(By.id(element)));
        } catch (Exception e) {
            TestLogger.logMsg("Wait waitForElementPresence : + " + this.getTimeStamp());
        }
    }
    TestLogger.logMsg("Done waitForElementPresence : + " + this.getTimeStamp());
}

From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java

License:Open Source License

protected void waitForElementPresence(final By by) {

    TestLogger.logMsg("Start waitForElementPresence : + " + this.getTimeStamp());
    for (int i = 0; i < 1; i++) {
        try {/*from www  . j a  v a  2  s  . co  m*/
            WebElement myDynamicElement = (new WebDriverWait(driver, TestUtils.timeout))
                    .until(ExpectedConditions.elementToBeClickable(by));
        } catch (Exception e) {
            TestLogger.logMsg("Wait waitForElementPresence : + " + this.getTimeStamp());
        }

    }
    TestLogger.logMsg("Done waitForElementPresence : + " + this.getTimeStamp());
}

From source file:com.cognifide.aet.job.common.SeleniumWaitHelper.java

License:Apache License

public static void waitForElementToBeClickable(WebDriver webDriver, By elementLocator, long timeOut) {
    WebDriverWait wait = new WebDriverWait(webDriver, timeOut);
    wait.until(ExpectedConditions.elementToBeClickable(elementLocator));
}

From source file:com.cognifide.bdd.demo.po.publish.pages.CartPage.java

License:Apache License

public void checkout() {
    bobcatWait.withTimeout(Timeouts.MEDIUM)
            .until(driver -> ExpectedConditions.elementToBeClickable(checkoutButton));
    reportEntryLogger.info("checkout link href attribute: '{}'",
            checkoutButton.getAttribute(HtmlTags.Attributes.HREF));
    //clicking on an anchor tag is sometimes problematic when using WebElement#click
    ((JavascriptExecutor) webDriver).executeScript("arguments[0].click();", checkoutButton);
    reportEntryLogger.info("checkout link clicked");
}

From source file:com.cognifide.qa.bb.aem.dialog.classic.field.image.AemImageSetterHelper.java

License:Apache License

private void findImageInContentFinder(final String imageName) {
    frameSwitcher.switchTo("/");
    AemContentFinder aemContentFinder = pageObjectInjector.inject(AemContentFinder.class);
    LOG.debug("injected content finder: '{}'", aemContentFinder);
    aemContentFinder.search(imageName);/* w  w w.j ava 2s  .c o  m*/
    AemContentFinderTab currentTab = aemContentFinder.getCurrentTab();
    aemContentFinder.changeToListViewIfNeeded(currentTab);
    WebElement image = currentTab.getImageWebElementByName(imageName);
    bobcatWait.withTimeout(Timeouts.MEDIUM).until(ExpectedConditions.elementToBeClickable(image));
    image.click();
    frameSwitcher.switchBack();
}

From source file:com.cognifide.qa.bb.aem.ui.AemContentTree.java

License:Apache License

private void clickNodeLabelAndWaitForClass(final WebElement node, final String expectedCssClass) {
    WebElement clickableArea = getNodeContent(node, By.cssSelector("div > a > span"));

    BobcatWebDriverWait wait = bobcatWait.withTimeout(Timeouts.SMALL);
    wait.until(ExpectedConditions.elementToBeClickable(clickableArea));
    wait.until(driver -> {//from w w w .  j av a 2  s . c  o  m
        clickableArea.click();
        return getNodeContent(node, By.cssSelector("div")).getAttribute(HtmlTags.Attributes.CLASS)
                .contains(expectedCssClass);
    });
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.elements.SiteAdminGrid.java

License:Apache License

/**
 * Waits for loader (mask that covers the grid after some actions) to disappear.
 *
 * @return This SiteadminGrid/*ww  w .  ja  v  a2  s .  c  o  m*/
 */
public SiteAdminGrid waitForLoaderNotPresent() {
    bobcatWait.withTimeout(Timeouts.BIG)
            .until(CommonExpectedConditions.elementNotPresentOrVisible(LOADER_LOCATOR));
    bobcatWait.withTimeout(Timeouts.SMALL).until(ExpectedConditions.elementToBeClickable(scrollPane));
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.window.ConfirmationWindow.java

License:Apache License

private void clickButton(final String buttonLabel) {
    final WebElement button = bobcatWait.withTimeout(Timeouts.BIG)
            .until(input -> window.findElement(By.xpath(String.format(BUTTON_XPATH_FORMATTED, buttonLabel))));

    bobcatWait.withTimeout(Timeouts.MEDIUM).until(ExpectedConditions.elementToBeClickable(button));

    bobcatWait.withTimeout(Timeouts.BIG).until(input -> {
        boolean confirmationWindowClosed;
        try {/*w  w w . jav a  2  s .  com*/
            button.click();
            confirmationWindowClosed = !window.isDisplayed();
        } catch (NoSuchElementException | StaleElementReferenceException e) {
            LOG.debug("Confirmation window is not available", e);
            confirmationWindowClosed = true;
        }
        return confirmationWindowClosed;
    });
}

From source file:com.cognifide.qa.bb.loadable.condition.impl.ClickabilityCondition.java

License:Apache License

@Override
public boolean check(Object object, LoadableComponent data) {
    if (object instanceof WebElement) {
        WebElement subject = (WebElement) object;
        return wait.withTimeout(data.timeout())
                .until(ignored -> ExpectedConditions.elementToBeClickable(subject), data.delay())
                .apply(null) != null;//w  w w.j a v a  2 s  .co m
    }
    throw new LoadableConditionException("Loadable Component Condition placed on not applicable field");
}