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:net.codestory.simplelenium.filters.LazyShould.java

License:Apache License

private static boolean isSelected(WebElement element) {
    return isSelectable(element) && element.isSelected();
}

From source file:net.codestory.simplelenium.filters.LazyShould.java

License:Apache License

private static String selectedStatus(WebElement element) {
    return isSelectable(element) ? element.isSelected() ? "selected" : "not selected" : "not selectable";
}

From source file:net.freifunk.autodeploy.selenium.ActorImpl.java

License:Apache License

@Override
public void updateCheckbox(final By by, final boolean checked) {
    LOG.trace("updateCheckbox: {}, {}", by, checked);
    waitForClickableElement(by);/*from w  w w  .  jav a2s. c o m*/
    final WebElement checkbox = getElement(by);
    Preconditions.checkState(
            "input".equals(checkbox.getTagName()) && "checkbox".equals(checkbox.getAttribute("type")),
            "Element should be a checkbox: {}", checkbox);
    if (checkbox.isSelected() != checked) {
        checkbox.click();
    }
    _wait.until(elementSelectionStateToBe(by, checked));
    LOG.trace("updateCheckbox done: {}, {}", by, checked);
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public boolean isCheckboxSelected(String checkBoxName) {
    WebElement e = getWebElementByXPath(
            "//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
    return e.isSelected();
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public boolean isCheckboxSelected(String checkBoxName, String checkBoxValue) {
    WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName)
            + " and @value=" + escapeQuotes(checkBoxValue) + "]", true, true);
    return e.isSelected();
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void checkCheckbox(String checkBoxName) {
    WebElement e = getWebElementByXPath(
            "//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
    if (!e.isSelected()) {
        e.click();/*from   w  w w  .  ja  v a 2 s . co m*/
    }
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void checkCheckbox(String checkBoxName, String checkBoxValue) {
    WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName)
            + " and @value=" + escapeQuotes(checkBoxValue) + "]", true, true);
    if (!e.isSelected()) {
        e.click();/* w  w w.jav a 2s  .co  m*/
    }
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void uncheckCheckbox(String checkBoxName) {
    WebElement e = getWebElementByXPath(
            "//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName) + "]", true, true);
    if (e.isSelected()) {
        e.click();/*w w  w  .  j  a va2s .c  o  m*/
    }
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public void uncheckCheckbox(String checkBoxName, String value) {
    WebElement e = getWebElementByXPath("//input[@type='checkbox' and @name=" + escapeQuotes(checkBoxName)
            + " and @value=" + escapeQuotes(value) + "]", true, true);
    if (e.isSelected()) {
        e.click();/*www  .  j  a  v a 2s .  com*/
    }
}

From source file:net.sourceforge.jwebunit.webdriver.WebDriverTestingEngineImpl.java

License:Open Source License

public String getSelectedRadio(String radioGroup) {
    List<WebElement> radios = getWebElementsByXPath(
            "/input[@type='radio' and @name=" + escapeQuotes(radioGroup) + "]");
    for (WebElement r : radios) {
        if (r.isSelected()) {
            return r.getAttribute("value");
        }/*from   w  w  w .ja va 2  s .  co  m*/
    }
    return null;
}