Example usage for org.openqa.selenium WebElement click

List of usage examples for org.openqa.selenium WebElement click

Introduction

In this page you can find the example usage for org.openqa.selenium WebElement click.

Prototype

void click();

Source Link

Document

Click this element.

Usage

From source file:com.cognifide.qa.bb.aem.expectedconditions.SidekickActions.java

License:Apache License

/**
 * Shows sidekick tab and checks if its active one now.
 *
 * @param tab tab to show//  w ww.  j a  v a2s  .co m
 * @return condition for active tab
 */
public static ExpectedCondition<Boolean> showSidekickTab(final WebElement tab) {
    return new ExpectedCondition<Boolean>() {
        @Override
        public Boolean apply(WebDriver driver) {
            tab.click();
            return tab.findElement(By.xpath(TAB_WRAPPER_XPATH)).getAttribute(HtmlTags.Attributes.CLASS)
                    .contains(TAB_ACTIVE);
        }

        @Override
        public String toString() {
            return "Tab is not ready";
        }
    };
}

From source file:com.cognifide.qa.bb.aem.expectedconditions.WindowActions.java

License:Apache License

/**
 * Clicks on button and check if its displayed.
 * <br>//from   w ww.j  a v a2s. c om
 * When button is not available it returns true.
 *
 * @param button button to click on
 * @return display of button or true if provided web element is not available
 */
public static ExpectedCondition<Boolean> clickButton(final WebElement button) {
    return input -> {
        try {
            button.click();
            return !button.isDisplayed();
        } catch (NoSuchElementException | StaleElementReferenceException e) {
            LOG.debug("Button is not available at the moment: '{}'", e);
            return true;
        }
    };
}

From source file:com.cognifide.qa.bb.aem.touch.pageobjects.touchui.dialogfields.text.FontFormat.java

License:Apache License

private void clickFormatButton(WebElement button) {
    controlToolbar.selectText();//  w  w  w  .  ja v  a 2 s  .  c o m
    bobcatWait.withTimeout(Timeouts.SMALL).until((ExpectedCondition<Object>) input -> button.isEnabled());
    button.click();
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem61.SiteadminToolbar.java

License:Apache License

public void movePage(String destination) {
    WebElement moveButton = getMoveButton();
    if (!moveButton.isDisplayed()) {
        getMoreButton().click();/*from   www .j a  v  a2  s  . co  m*/
    }
    moveButton.click();
    movePageWizard.moveToDestination(destination);
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem61.TemplateList.java

License:Apache License

void selectTemplate(String templateName) {
    WebElement template = templates.stream().filter(
            t -> StringUtils.equals(t.findElement(By.cssSelector("div.label > h4")).getText(), templateName))
            .findFirst().orElseThrow(() -> new IllegalArgumentException("Template not found: " + templateName));

    template.click();
}

From source file:com.cognifide.qa.bb.aem.touch.siteadmin.aem62.TemplateList.java

License:Apache License

void selectTemplate(String templateName) {
    WebElement template = templates.stream()
            .filter(t -> StringUtils.equals(
                    t.findElement(By.cssSelector("coral-card-content coral-card-title")).getText(),
                    templateName))//  w  ww .ja v  a  2s .  c o m
            .findFirst().orElseThrow(() -> new IllegalArgumentException("Template not found: " + templateName));

    template.click();
}

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 -> {// www . ja  v  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.AemDialog.java

License:Apache License

/**
 * Clicks OK button at the bottom of edit Window. Assumes invalid data was entered and waits for
 * the validation message to appear./*from  w  ww .  ja v a2  s  . c  om*/
 *
 * @return Returns instance of ValidationWindow.
 */
public ValidationWindow okExpectingValidation() {
    final WebElement okButton = getFooterButtonWebElement(OK_BUTTON_TEXT);

    bobcatWait.withTimeout(Timeouts.BIG).until((ExpectedCondition<Object>) input -> {
        try {
            okButton.click();
            return webElementHelper.isCurrentScopeVisible(validationWindow);
        } catch (NoSuchElementException | StaleElementReferenceException e) {
            LOG.debug("Dialog footer button is not available: {}", e);
            return Boolean.FALSE;
        }
    }, 2);
    return validationWindow;
}

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

License:Apache License

/**
 * Clicks button at the bottom of edit Window and expect for dialog to disappear.
 *
 * @param buttonText button label//from w ww . j a v a  2 s.c o  m
 * @return Returns this dialog instance.
 */
public AemDialog clickDialogFooterButton(final String buttonText) {
    final WebElement footerButton = getFooterButtonWebElement(buttonText);

    bobcatWait.withTimeout(Timeouts.BIG).until((ExpectedCondition<Object>) input -> {
        try {
            footerButton.click();
            footerButton.isDisplayed();
            return Boolean.FALSE;
        } catch (NoSuchElementException | StaleElementReferenceException | ElementNotVisibleException e) {
            LOG.debug("Dialog footer button is not available: {}", e);
            return Boolean.TRUE;
        }
    }, 2);
    bobcatWait.withTimeout(Timeouts.MEDIUM).until(CommonExpectedConditions.noAemAjax());
    return this;
}

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

License:Apache License

private WebElement chooseTab(String componentGroup) {
    try {//from w  ww. java2s. c  om
        WebElement tab = currentScope.findElement(By.xpath(
                String.format(".//*[contains(@class,'x-panel-header')][.//span[normalize-space(text())=%s]]",
                        XpathUtils.quote(componentGroup))));
        if (TAB_FOLDED
                .equals(tab.findElement(By.cssSelector(".x-tool-toggle")).getCssValue("background-position"))) {
            tab.click();
        }
        return tab;
    } catch (NoSuchElementException e) {
        throw new NoSuchElementException("No such tab: " + componentGroup, e);
    }
}