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:com.mgmtp.jfunk.web.util.WebElementFinder.java

License:Apache License

private boolean checkElementForList(final WebElement element) {
    if (enabled != null) {
        if (enabled != element.isEnabled()) {
            return false;
        }//from  w  w  w. j av  a  2s. c  om
    }
    if (displayed != null) {
        if (displayed != element.isDisplayed()) {
            return false;
        }
    }
    if (selected != null) {
        if (selected != element.isSelected()) {
            return false;
        }
    }
    return true;
}

From source file:com.mgmtp.jfunk.web.util.WebElementFinder.java

License:Apache License

private void checkElement(final WebElement element) {
    if (enabled != null) {
        if (enabled) {
            checkElementState(element, element.isEnabled(),
                    "Element '%s' was expected to be enabled but is not.");
        } else {/*from   ww  w.  jav  a 2  s. c om*/
            checkElementState(element, !element.isEnabled(),
                    "Element '%s' was expected to not be enabled but is.");
        }
    }
    if (displayed != null) {
        if (displayed) {
            checkElementState(element, element.isDisplayed(),
                    "Element '%s' was expected to be displayed but is not.");
        } else {
            checkElementState(element, !element.isDisplayed(),
                    "Element '%s' was expected to not be displayed but is.");
        }
    }
    if (selected != null) {
        if (selected) {
            checkElementState(element, element.isSelected(),
                    "Element '%s' was expected to be selected but is not.");
        } else {
            checkElementState(element, !element.isSelected(),
                    "Element '%s' was expected to not be selected but is.");
        }
    }
}

From source file:com.mkl.websuites.internal.command.impl.select.DeselectCheckboxCommand.java

License:Apache License

@Override
protected void selectCheckbox(WebElement elem) {
    if (elem.isSelected()) {
        elem.click();
    }
}

From source file:com.mkl.websuites.internal.command.impl.select.SelectCheckboxCommand.java

License:Apache License

protected void selectCheckbox(WebElement elem) {
    if (!elem.isSelected()) {
        elem.click();
    }
}

From source file:com.opera.core.systems.ElementsTest.java

License:Apache License

@Test
public void testSelect() {
    getFixture("select.html");
    WebElement el = driver.findElementById("dog");
    el.click();//  w  w w. j  a va  2s .  co m
    assertTrue(el.isSelected());
}

From source file:com.oracle.pgbu.p6web.helper.DataHelper.java

/**
* 
* @param check : True if the box has to be checked and false to uncheck
* @param checkBoxElement : Checkbox to be clicked
*//*from  w ww .  ja va 2s.c om*/
public boolean clickCheckBox(boolean check, WebElement checkBoxElement) {
    if (!check && checkBoxElement.isSelected()) {
        checkBoxElement.click();
        return true;
    }
    if (check && !checkBoxElement.isSelected()) {
        checkBoxElement.click();
        return true;
    }
    return false;
}

From source file:com.osbitools.ws.shared.xui.GenericGuiWebTest.java

License:LGPL

public WebElement checkElementIsSelected(String id, boolean selected) {
    WebElement el = driver.findElement(By.id(id));

    assertNotNull(el);//  w  w w  . j  ava  2 s  . com
    assertEquals(selected, el.isSelected());

    return el;
}

From source file:com.pearson.uitest.pageobjects.LicenseLandingPage.java

License:Open Source License

public boolean getDefaultOrgSelection(String licenseNameDropDown) {
    WebElement select = this.getLicenseDisplayDropdown();
    Select sel = new Select(select);
    sel.selectByIndex(0);//from  w  w  w . jav  a2s  .c  o m
    CommonHelper.nap();
    WebElement option = select
            .findElement(By.xpath("//option[contains(text(),'" + licenseNameDropDown + "')]"));
    log.info(option.getAttribute("text") + option.isSelected() + option.isDisplayed()
            + "\t//option[contains(text(),'" + licenseNameDropDown + "')]");
    return option.getAttribute("text").equals(licenseNameDropDown)
            || option.getAttribute("text").contains(licenseNameDropDown);
}

From source file:com.qmetry.qaf.automation.data.ElementInteractor.java

License:Open Source License

public Object fetchValue(String loc, Type type, Class<? extends QAFExtendedWebElement> eleClass) {
    try {//ww w .  j ava 2 s  .  c om
        WebElement ele = getElement(loc, eleClass);
        switch (type) {
        case optionbox:
            return ele.getAttribute("value");
        case checkbox:
            return ele.isSelected();
        case selectbox:
            return new SelectBox(loc).getSelectedLable();
        case multiselectbox:
            return new SelectBox(loc).getSelectedLables();
        default:
            return ele.getText();
        }
    } catch (Exception e) {
        logger.warn(e.getMessage());
        return "";
    }
}

From source file:com.qulix.ft.teachingSite.Conditions.ExpectedConditions.java

License:Apache License

/**
 * An expectation for checking if the given element is selected.
 *///from  w w w  .  ja v  a 2s.  co m
public static ExpectedCondition<Boolean> elementSelectionStateToBe(final WebElement element,
        final boolean selected) {
    return new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver from) {
            return element.isSelected() == selected;
        }

        @Override
        public String toString() {
            return String.format("element (%s) to %sbe selected", element, (selected ? "" : "not "));
        }
    };
}