Example usage for org.openqa.selenium WebElement isSelected

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

Introduction

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

Prototype

boolean isSelected();

Source Link

Document

Determine whether or not this element is selected or not.

Usage

From source file:nz.co.testamation.core.client.SeleniumBrowserDriver.java

License:Apache License

@Override
public void setCheckBoxState(String name, boolean desiredState) {
    final WebElement element = findElement(By.name(name));
    if (element.isSelected() != desiredState) {
        element.click();/*from w w  w.  java 2  s  .co m*/
    }
}

From source file:nz.co.testamation.core.client.SeleniumBrowserDriver.java

License:Apache License

@Override
public void setCheckBoxState(String name, String value, boolean desiredState) {
    final WebElement element = findElement(
            By.cssSelector(String.format("input[name='%s'][value='%s']", name, value)));
    if (element.isSelected() != desiredState) {
        element.click();/* ww w .  j  a v a2s.co  m*/
    }
}

From source file:org.alfresco.po.share.cmm.admin.CreateNewPropertyPopUp.java

License:Open Source License

/**
 * Click the constraint requires match field.
 * //from  www .j a v  a  2 s  .c o  m
 * @return the CreateNewPropertyPopUp
 */
public void clickConstraintRequiresMatchField() {
    try {
        WebElement checkBoxParent = findAndWait(CONSTRAINT_REQUIRES_MATCH_FIELD);
        WebElement checkBox = checkBoxParent.findElement(By.cssSelector("input"));
        checkBox.click();
        if (!checkBox.isSelected()) {
            throw new PageOperationException("Unable to select CheckBox: " + CONSTRAINT_REQUIRES_MATCH_FIELD);
        }
    } catch (TimeoutException toe) {
        throw new PageOperationException("Not visible Element: CONSTRAINT_REQUIRES_MATCH_FIELD", toe);
    }
}

From source file:org.alfresco.po.share.cmm.admin.CreateNewPropertyPopUp.java

License:Open Source License

/**
 * Click the constraint sorted field.//from  w w  w  . j  a v  a 2  s  . c o  m
 * 
 * @return the CreateNewPropertyPopUp
 */
public void clickConstraintSortedField() {
    try {
        WebElement checkBoxParent = findAndWait(CONSTRAINT_SORTED_FIELD);
        WebElement checkBox = checkBoxParent.findElement(By.cssSelector("input"));
        checkBox.click();
        // Added to get the focus on <Create> button
        checkBox.sendKeys(Keys.TAB);
        if (!checkBox.isSelected()) {
            throw new PageOperationException("Unable to select CheckBox: " + CONSTRAINT_SORTED_FIELD);
        }
    } catch (TimeoutException toe) {
        throw new PageOperationException("Not visible Element: CONSTRAINT_SORTED_FIELD ", toe);
    }
}

From source file:org.alfresco.po.share.cmm.admin.EditPropertyPopUp.java

License:Open Source License

/**
 * Click the constraint requires match field.
 * //from www.jav a 2 s .  c  o  m
 * @return the CreateNewPropertyPopUp
 */
public void clickConstraintRequiresMatchField() {
    try {
        WebElement checkBoxParent = findAndWait(CONSTRAINT_REQUIRES_MATCH_FIELD);
        WebElement checkBox = checkBoxParent.findElement(By.cssSelector("input"));
        checkBox.click();
        if (!checkBox.isSelected()) {
            throw new PageOperationException("Unable to select CheckBox: " + CONSTRAINT_REQUIRES_MATCH_FIELD);
        }
    } catch (TimeoutException toe) {
        throw new PageOperationException("Not visible Element: CONSTRAINT_REQUIRES_MATCH_FIELD ", toe);
    }
}

From source file:org.alfresco.po.share.cmm.admin.EditPropertyPopUp.java

License:Open Source License

/**
 * Click the constraint sorted field./*  w w  w.j  ava  2 s .  com*/
 * 
 * @return the CreateNewPropertyPopUp
 */
public void clickConstraintSortedField() {
    try {
        WebElement checkBoxParent = findAndWait(CONSTRAINT_SORTED_FIELD);
        WebElement checkBox = checkBoxParent.findElement(By.cssSelector("input"));
        checkBox.click();
        if (!checkBox.isSelected()) {
            throw new PageOperationException("Unable to select CheckBox: " + CONSTRAINT_SORTED_FIELD);
        }
    } catch (TimeoutException toe) {
        throw new PageOperationException("Not visible Element: CONSTRAINT_SORTED_FIELD ", toe);
    }
}

From source file:org.alfresco.po.share.dashlet.RssFeedUrlBoxPage.java

License:Open Source License

/**
 * Method to verify if 'Open links in new window' is checked
 * /*  w ww  . ja v  a 2 s.com*/
 * @return true if checked
 */
public boolean isLinkNewWindowSelected() {
    boolean selected;
    try {
        WebElement element = driver.findElement(CHK_OPEN_IN_NEW_WINDOW);
        selected = element.isSelected();
        return selected;
    } catch (NoSuchElementException te) {
        return false;
    }
}

From source file:org.alfresco.po.share.EditUserPage.java

License:Open Source License

/**
 * Selects the Disable Account checkbox.
 *///from w w w  . j a  v  a 2 s.  c  om
public void selectDisableAccount() {
    try {
        WebElement selectDisableAccount = driver.findElement(By.cssSelector(DISABLE_ACCOUNT));
        if (!selectDisableAccount.isSelected()) {
            selectDisableAccount.click();
        }
    } catch (NoSuchElementException te) {
    }
}

From source file:org.alfresco.po.share.EditUserPage.java

License:Open Source License

/**
 * Deselects the Disable Account checkbox.
 *///from   w  w w.  j  av a2 s  . co  m
public void deSelectDisableAccount() {
    try {
        WebElement selectDisableAccount = driver.findElement(By.cssSelector(DISABLE_ACCOUNT));
        if (selectDisableAccount.isSelected()) {
            selectDisableAccount.click();
        }
    } catch (NoSuchElementException te) {
    }
}

From source file:org.alfresco.po.share.ShareDialogueAikau.java

License:Open Source License

/**
 * Checks if the checkbox type input field is selected.
 * // w w  w  .j av a  2 s .co m
 * @return true, if the field is selected
 */
public boolean isCheckBoxSelected(By selector) {
    try {
        WebElement checkBoxParent = findAndWait(selector);

        WebElement checkBox = checkBoxParent.findElement(By.cssSelector("input"));

        return checkBox.isSelected();
    } catch (Exception e) {
        LOGGER.info("Exception while checking if field is selected", e);
    }
    return false;
}