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.alfresco.po.share.site.links.LinkDirectoryInfo.java

License:Open Source License

/**
 * Check is selected./*from  ww  w .  ja v a  2s.  c o  m*/
 *
 * @return boolean
 */
public boolean isSelected() {
    WebElement element = findElement(SELECT);
    return element.isSelected();
}

From source file:org.aludratest.service.gui.web.selenium.selenium2.Selenium2Wrapper.java

License:Apache License

public boolean isChecked(GUIElementLocator locator) {
    WebElement element = doBeforeDelegate(locator, true, false, false);
    LOGGER.debug("isChecked({})", locator);
    Boolean returnValue = element.isSelected();
    doAfterDelegate(-1, "isChecked");
    return returnValue.booleanValue();
}

From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java

License:Apache License

public void checkField(String locator) {
    WebElement element = findElement(locator);
    if (!element.isSelected()) {
        element.click();//from   w ww.  j  a v a2 s .  co  m
    }
}

From source file:org.apache.archiva.web.test.parent.AbstractSeleniumTest.java

License:Apache License

public void uncheckField(String locator) {
    WebElement element = findElement(locator);
    if (element.isSelected()) {
        element.click();// ww w.j  a  va  2 s . c o m
    }
}

From source file:org.apache.falcon.regression.ui.search.AbstractSearchPage.java

License:Apache License

/**
 * Method imitates click on check box. If click is not performed method retries the click.
 * @param expectedState whether check box is expected to be enabled or not after click.
 *///from   ww w  .  j  a v a 2  s. c  o m
protected void clickCheckBoxSecurely(WebElement checkBox, boolean expectedState) {
    double gap = 0.5;
    for (int attempt = 1; attempt <= (DEFAULT_TIMEOUT / gap); attempt++) {
        LOGGER.info("Attempt to click a check box: " + attempt);
        checkBox.click();
        if (checkBox.isSelected() == expectedState) {
            return;
        }
        TimeUtil.sleepSeconds(gap);
    }
    Assert.fail("Check box state was not changed even in " + DEFAULT_TIMEOUT + " seconds.");
}

From source file:org.apache.nutch.protocol.interactiveselenium.handlers.SearchHandler.java

License:Apache License

private String genericSearchHandler(WebDriver webDriver, String htmlpage, String searchWindowPath,
        String searchInputPath, String searchButtonPath, String searchRadioButtonPath, String searchKey) {
    webDriver.manage().window().maximize();
    try {/*from  w  ww . jav  a 2s  .c o  m*/
        WebElement findSearchWindow = webDriver.findElement(By.xpath(searchWindowPath));
        if (findSearchWindow.isDisplayed())
            findSearchWindow.click();
        WebElement classifiedRadioBtn = webDriver.findElement(By.xpath(searchRadioButtonPath));
        if (classifiedRadioBtn.isSelected())
            classifiedRadioBtn.click();
        WebElement username = webDriver.findElement(By.xpath(searchInputPath));
        if (username.isDisplayed())
            username.sendKeys(searchKey);
        WebElement loginBtn = webDriver.findElement(By.xpath(searchButtonPath));
        if (loginBtn.isDisplayed())
            loginBtn.click();
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        htmlpage += webDriver.findElement(By.tagName("body")).getAttribute("innerHTML");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return htmlpage;
}

From source file:org.apache.portals.pluto.demo.integration.test.AsyncDemoIT.java

License:Apache License

private boolean isChecked(String xpath) {
    WebElement checkbox = driver.findElement(By.xpath(xpath));
    return checkbox.isSelected();
}

From source file:org.apache.portals.pluto.demo.integration.test.PortletHubDemoIT.java

License:Apache License

private void handleColorCheckbox(String colorName, boolean colorSelected) {

    WebElement colorCheckbox = driver
            .findElement(By.xpath(getXpath("input", "hub_demo_portlet", "PH", "ColorSelPortlet", colorName)));

    if ((colorSelected && !colorCheckbox.isSelected()) || (!colorSelected && colorCheckbox.isSelected())) {
        colorCheckbox.click();/*w  w w . ja v a 2 s. c o m*/
    }
}

From source file:org.arquillian.droidium.showcase.recorder.test01.DroidiumRecordingTestCase.java

License:Apache License

@Test
@InSequence(2)//from  w w  w .ja  v a2  s.  com
public void test02() throws Exception {

    // check value in name field, clear it and write new one
    WebElement inputName = driver.findElement(By.id("inputName"));
    Assert.assertEquals(inputName.getText(), USER_REAL_OLD);
    inputName.clear();
    inputName.sendKeys(USER_REAL_NAME);
    Assert.assertEquals(inputName.getText(), USER_REAL_NAME);

    //
    // stops 1st recording of video on Android
    //
    device.stopRecording(VIDEO_1);

    //
    // starts 2nd recording of video on Android
    //
    device.startRecording(new ScreenrecordOptions.Builder().build());

    // enter favorite language
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(USER_PRGRAMMING_LANGUAGE)).click();

    // accept adds checkbox
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);

    acceptAddsCheckbox.click();

    // register
    driver.findElement(By.id("btnRegisterUser")).click();

    //
    // stops 2nd recording of video on Android
    //
    device.stopRecording(VIDEO_2);

    Assert.assertTrue(VIDEO_1.exists());
    Assert.assertTrue(VIDEO_2.exists());
}

From source file:org.arquillian.droidium.showcase.recorder.test02.DroidiumRecordingTestCase.java

License:Apache License

@Test
@InSequence(2)// w w  w.  ja  v a  2  s .  c  o  m
public void test02() throws Exception {

    // check value in name field, clear it and write new one
    WebElement inputName = driver.findElement(By.id("inputName"));
    Assert.assertEquals(inputName.getText(), USER_REAL_OLD);
    inputName.clear();
    inputName.sendKeys(USER_REAL_NAME);
    Assert.assertEquals(inputName.getText(), USER_REAL_NAME);

    // enter favorite language
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(USER_PRGRAMMING_LANGUAGE)).click();

    // accept adds checkbox
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);

    acceptAddsCheckbox.click();

    // register
    driver.findElement(By.id("btnRegisterUser")).click();
}