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.ui.sidekick.AemSidekick.java

License:Apache License

/**
 * Finds the button associated with the selected view mode and clicks it.
 *
 * @param iconName sidekick view modes//from   w  ww.  j  av  a 2 s. c  om
 * @return This AemSidekick instance.
 */
public AemSidekick clickModeIcon(ModeIcon iconName) {
    final String xpath = String.format(ICON_BOTTOM_XPATH, iconName.getIconName());
    final WebElement iconBottom = driver.findElement(By.xpath(xpath));
    iconBottom.click();

    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreatePageWindow.java

License:Apache License

/**
 * Selects the template containing provided name.
 *
 * @param templateName partial template name
 * @return this CreatePageWindow/*from w w  w  .  j a v  a  2 s.co  m*/
 */
public CreatePageWindow selectTemplateContaining(String templateName) {
    WebElement template = currentWindow.findElement(By.xpath(
            ".//div[contains(@class, " + "'template-title') and contains(text(), '" + templateName + "')]"));
    template.click();
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreatePageWindow.java

License:Apache License

/**
 * Selects the template that matches exactly the provided value.
 *
 * @param exactTemplateName exact template name
 * @return this CreatePageWindow/*from w  w w .  j a  va2s  .c o m*/
 */
public CreatePageWindow selectTemplate(String exactTemplateName) {
    WebElement template = currentWindow.findElement(By.xpath(
            ".//div[contains(@class, " + "'template-title') and text() = \"" + exactTemplateName + "\"]"));
    template.click();
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreateSiteWindow.java

License:Apache License

/**
 * Selects the template containing provided name.
 *
 * @param templateName partial template name
 * @return this CreatePageWindow//from  w w w.  jav  a  2s . com
 */
public CreateSiteWindow selectTemplateContaining(String templateName) {
    WebElement template = currentWindow.findElement(By.xpath(
            ".//div[contains(@class, " + "'template-title') and contains(text(), '" + templateName + "')]"));
    template.click();
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreateSiteWindow.java

License:Apache License

/**
 * Selects the template that matches exactly the provided value.
 *
 * @param exactTemplateName exact template name
 * @return this CreatePageWindow/*from w w w.  jav a2  s  .co  m*/
 */
public CreateSiteWindow selectTemplate(String exactTemplateName) {
    WebElement template = currentWindow.findElement(By.xpath(
            ".//div[contains(@class, " + "'template-title') and text() = \"" + exactTemplateName + "\"]"));
    template.click();
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreateSiteWindow.java

License:Apache License

/**
 * Fill data on Live copy view//from   w  ww  .  j  a  va 2  s. c  o m
 *
 * @param siteOwner site owner name
 * @param liveCopy live copy
 * @param rollOutConfigs list of roll out configurations
 * @return this CreateSiteWindow
 */
public CreateSiteWindow fillLiveCopy(String siteOwner, boolean liveCopy, List<String> rollOutConfigs) {
    ownerDropDown.selectByText(siteOwner);
    WebElement checkBox = currentWindow.findElement(By.name("isLiveCopy"));
    if (!liveCopy) {
        checkBox.click();
    }

    for (String config : rollOutConfigs) {
        currentWindow.findElement(By.xpath("//span[text()='Add Item']")).click();
        List<WebElement> inputs = currentWindow
                .findElements(By.xpath("//img[@src='/libs/cq/ui/resources/0.gif']"));
        inputs.get(inputs.size() - 1).click();
        List<WebElement> options = currentWindow.findElements(By.xpath("//div[text()='" + config + "']"));
        options.stream().filter(WebElement::isDisplayed).forEach(org.openqa.selenium.WebElement::click);
    }
    return this;
}

From source file:com.cognifide.qa.bb.aem.ui.wcm.windows.CreateSiteWindow.java

License:Apache License

private void clickLanguageCheckBox(String language) {
    WebElement span = currentWindow.findElement(By.xpath("//span[contains(text(),'" + language + "')]"));
    WebElement label = span.findElement(By.xpath(".."));
    WebElement checkBox = currentWindow.findElement(By.id(label.getAttribute("for")));
    checkBox.click();
}

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 {//from   ww  w  .  ja v  a2 s. c  o  m
            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.utils.WebElementUtils.java

License:Apache License

/**
 * Checks if WebElement with specified name is present on the specified list and clicks it if
 * it is on the list./*from w w w .  j  a  va2  s .  co  m*/
 *
 * @param elements    list of WebElements within which the specified WebElement is searched.
 * @param elementName name of the WebElement to be clicked.
 * @return WebElement that has been clicked.
 * @throws IllegalArgumentException if element with specified name is not on the list.
 */
public WebElement clickElementIfExists(final List<WebElement> elements, final String elementName) {
    for (WebElement element : elements) {
        if (elementName.equals(element.getText())) {
            element.click();
            return element;
        }
    }
    throw new IllegalArgumentException(String.format("There is no element named %s", elementName));
}

From source file:com.comcast.dawg.house.AdvanceFilterNavigator.java

License:Apache License

public void checkConditions(boolean check, String... conditionTexts) {
    WebElement conditionList = driver.findElementByClassName(IndexPage.CONDITION_LIST);
    List<WebElement> conditions = conditionList.findElements(By.tagName("div"));

    for (String conditionText : conditionTexts) {
        WebElement condition = getCondition(conditions, conditionText, true);
        WebElement conditionCheckBox = condition.findElement(By.className(IndexPage.CONDITION_CHECK_BOX));
        if (conditionCheckBox.isSelected() != check) {
            conditionCheckBox.click();
        }/*from  www .  j  a  v a  2s . c o  m*/
    }
}