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:org.eclipse.skalli.selenium.pageobjects.ext.editform.RelatedProjectsExtensionEditForm.java

License:Open Source License

public void checkCalculateRelatedProjectCheckBox(boolean checked) {
    WebElement calculateRelatedProjectCheckBox = getCalculateRelatedProjectsCheckBox();

    if (checked && !calculateRelatedProjectCheckBox.isSelected()) {
        calculateRelatedProjectCheckBox.click();
    }// www.  j  a v a  2s .  c  om

    if (!checked && calculateRelatedProjectCheckBox.isSelected()) {
        calculateRelatedProjectCheckBox.click();
    }
}

From source file:org.eclipse.skalli.selenium.pageobjects.ext.editform.RelatedProjectsExtensionEditForm.java

License:Open Source License

public boolean isCalculateRelatedProjectCheckBoxChecked() {
    WebElement calculateRelatedProjectCheckBox = getCalculateRelatedProjectsCheckBox();

    return calculateRelatedProjectCheckBox.isSelected();
}

From source file:org.finra.jtaf.ewd.widget.element.html.CheckBox.java

License:Apache License

/**
 * /*from   w  ww .j  a  va 2 s  .c  o m*/
 * @param e
 *            WebElement to check
 * @return boolean if attribute is selected
 * @throws Exception
 */
private static boolean isSelected(WebElement e) throws Exception {
    try {
        return e.isSelected();
    } catch (Exception exception) {
        try {
            String attribute = e.getAttribute("value");
            return attribute != null && attribute.equalsIgnoreCase("on");
        } catch (Exception exception2) {
            throw exception;
        }
    }
}

From source file:org.glowroot.tests.ConfigIT.java

License:Apache License

@Test
public void shouldUpdatePluginConfig() throws Exception {
    // given//from  w  w w  . j  a  v a2 s .co m
    App app = app();
    GlobalNavbar globalNavbar = globalNavbar();
    ConfigSidebar configSidebar = new ConfigSidebar(driver);

    app.open();
    globalNavbar.getConfigLink().click();
    configSidebar.getPluginsLink().click();

    Utils.withWait(driver, By.linkText("Jdbc Plugin")).click();
    Utils.withWait(driver, By.xpath("//div[@gt-label='Bind parameters']//input")).click();
    Utils.withWait(driver, By.xpath("//button[normalize-space()='Save changes']")).click();

    // wait for save to finish
    Thread.sleep(1000);

    // then
    app.open();
    globalNavbar.getConfigLink().click();
    configSidebar.getPluginsLink().click();

    Utils.withWait(driver, By.linkText("Jdbc Plugin")).click();
    WebElement element = Utils.withWait(driver, By.xpath("//div[@gt-label='Bind parameters']//input"));
    assertThat(element.isSelected()).isFalse();
}

From source file:org.jboss.arquillian.graphene.angular.ftest.pageobjects.TodoList.java

License:Apache License

public List<TodoItem> openTasks() {
    final List<WebElement> currentTodos = driver.findElements(ByAngular.repeat("todo in todos"));
    return Lists.transform(currentTodos, new Function<WebElement, TodoItem>() {
        @Override//w  ww.jav  a  2s  .  c  o m
        public TodoItem apply(WebElement input) {
            final WebElement checkbox = input.findElement(By.tagName("input"));
            final WebElement description = input.findElement(By.tagName("span"));
            return new TodoItem(description.getText(), checkbox.isSelected());
        }
    });
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

public void checkboxShouldBeSelected(String locator) {
    WebElement el = getCheckbox(locator);

    LOG.createAppender().appendBold("Checkbox Should Be Selected:").appendCss(locator)
            .appendProperty("Selected", el.isSelected()).log();

    if (!el.isSelected()) {
        throw new IllegalArgumentException("Checkbox should have been selected.");
    }//from w w w.  j  av a 2 s . c  o m
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

public void checkboxShouldNotBeSelected(String locator) {
    WebElement el = getCheckbox(locator);

    LOG.createAppender().appendBold("Checkbox Should Not e Selected:").appendCss(locator)
            .appendProperty("Selected", el.isSelected()).log();

    if (el.isSelected()) {
        throw new IllegalArgumentException("Checkbox should not have been selected.");
    }/*w w  w .ja  v a2s  . c  o m*/
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

public void selectedTextValueInListShouldBe(String locator, String selectedText) {
    List<WebElement> selectOptions = getSelectListOptions(locator);

    boolean textIsSelected = false;

    for (WebElement selected : selectOptions) {
        if (selected.isSelected() && selected.getText().equalsIgnoreCase(selectedText)) {
            textIsSelected = true;/*w  ww. j  a  v  a 2s . c om*/
            break;
        }
    }

    if (!textIsSelected) {
        //throw new AssertionError(String.format("Value %s was not selected from list '%s'", locator, selectedText));
        throw new AssertionError(String.format("Value was not selected from list"));
    }
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

public void selectAllFromList(String locator) {
    LOG.createAppender().appendBold("Select All From List:").appendCss(locator).log();

    WebElement selectEl = getSelectList(locator);
    boolean isMultiSelectList = isMultiSelectList(selectEl);

    if (!isMultiSelectList) {
        LOG.createAppender().appendProperty("multi-select", isMultiSelectList).log();

        throw new IllegalArgumentException("Keyword 'Select all from list' works only for multi-select lists.");
    }//from ww  w  . j  a  v  a  2s  .  c  o m

    HighlightRobotLogger.HtmlAppender appender = LOG.createAppender();

    List<WebElement> selectOptions = getSelectListOptions(selectEl);
    int index = 0;
    for (WebElement option : selectOptions) {
        if (!option.isSelected()) {
            appender.appendProperty(
                    String.format("option[index=%d,value=%s]", index++, option.getAttribute("value")),
                    option.getText());
            option.click();
        } else {
            appender.appendProperty(
                    String.format("option[index=%d,value=%s]", index++, option.getAttribute("value")),
                    option.getText() + ": (already selected)");
        }
    }

    appender.log();
}

From source file:org.jspringbot.keyword.selenium.SeleniumHelper.java

License:Open Source License

public void unselectAllFromList(String locator) {
    LOG.createAppender().appendBold("Unselect All From List:").appendCss(locator).log();

    WebElement selectEl = getSelectList(locator);
    boolean isMultiSelectList = isMultiSelectList(selectEl);

    if (!isMultiSelectList) {
        LOG.createAppender().appendProperty("multi-select", isMultiSelectList).log();

        throw new IllegalArgumentException(
                "Keyword 'Unselect all from list' works only for multi-select lists.");
    }// w  w w  .j a va2  s .com

    HighlightRobotLogger.HtmlAppender appender = LOG.createAppender();

    List<WebElement> selectOptions = getSelectListOptions(selectEl);
    int index = 0;
    for (WebElement option : selectOptions) {
        if (option.isSelected()) {
            appender.appendProperty(
                    String.format("option[index=%d,value=%s]", index++, option.getAttribute("value")),
                    option.getText());
            option.click();
        } else {
            appender.appendProperty(
                    String.format("option[index=%d,value=%s]", index++, option.getAttribute("value")),
                    option.getText() + ": (already unselected)");
        }
    }

    appender.log();
}