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.openlmis.pageobjects.ReportPage.java

License:Open Source License

public boolean isParameterFalseOptionSelected(String displayName) {
    WebElement element = testWebDriver.getElementById("false_" + displayName);
    testWebDriver.waitForElementToAppear(element);
    return element.isSelected();
}

From source file:org.openlmis.pageobjects.RequisitionPage.java

License:Open Source License

public void verifySkippedProductsOnRnRScreen(int rowNumber) {
    testWebDriver.waitForAjax();/*  www  .j a va2  s  .  c om*/
    WebElement skipCheckBox = testWebDriver.getElementById("skip_" + (rowNumber - 1));
    testWebDriver.waitForElementToAppear(skipCheckBox);
    assertTrue(skipCheckBox.isSelected());
    skipCheckBox = testWebDriver.getElementById("skip_" + (rowNumber));
    assertFalse(skipCheckBox.isSelected());
}

From source file:org.openlmis.pageobjects.TemplateConfigPage.java

License:Open Source License

private void clickCheckBox(WebElement chkBox) {
    testWebDriver.waitForElementToAppear(chkBox);
    if (!chkBox.isSelected())
        chkBox.click();/* www .  j av  a  2 s . com*/
    testWebDriver.sleep(100);
}

From source file:org.openlmis.pageobjects.TemplateConfigPage.java

License:Open Source License

private void unClickCheckBox(WebElement chkBox) {
    testWebDriver.waitForElementToAppear(chkBox);
    if (chkBox.isSelected())
        chkBox.click();/* ww  w  . j a va2s.c om*/
    testWebDriver.sleep(100);
}

From source file:org.openlmis.UiUtils.TestWebDriver.java

License:Open Source License

public void clickForRadio(final WebElement element) {
    element.click();//  ww  w .j a  va  2  s . co  m
    if (!element.isSelected()) {
        Actions action = new Actions(driver);
        action.click(element).perform();
    }
}

From source file:org.opennms.smoketest.OpenNMSSeleniumTestCase.java

License:Open Source License

protected void setChecked(final By by) {
    final WebElement element = m_driver.findElement(by);
    if (element.isSelected()) {
        return;/*w  ww  . j  a  v  a2  s  .  com*/
    } else {
        element.click();
    }
}

From source file:org.opennms.smoketest.OpenNMSSeleniumTestCase.java

License:Open Source License

protected void setUnchecked(final By by) {
    final WebElement element = m_driver.findElement(by);
    if (element.isSelected()) {
        element.click();//from  w  w w  . ja  v  a  2  s.c o  m
    } else {
        return;
    }
}

From source file:org.openqa.selendroid.tests.UserRegistrationTest.java

License:Apache License

private void registerUser(UserDO user) throws Exception {
    WebElement button = driver.findElement(By.id("startUserRegistration"));
    takeScreenShot("Main Activity started.");
    button.click();//w  w w .ja  v a  2 s  .c o  m

    WebDriverWait wait = new WebDriverWait(driver, 5);
    WebElement inputUsername = wait.until(ExpectedConditions.presenceOfElementLocated(By.id("inputUsername")));
    inputUsername.sendKeys(user.getUsername());
    driver.findElement(By.id("inputEmail")).sendKeys(user.getEmail());
    driver.findElement(By.id("inputPassword")).sendKeys(user.getPassword());
    WebElement nameInput = driver.findElement(By.id("inputName"));
    Assert.assertEquals(nameInput.getText(), "Mr. Burns");
    nameInput.clear();
    try {
        nameInput.submit();
        Assert.fail("submit is not supported by SelendroidNativeDriver");
    } catch (WebDriverException e) {
        // expected behavior
    }
    nameInput.sendKeys(user.getName());
    driver.findElement(By.id("input_preferedProgrammingLanguage")).click();
    driver.findElement(By.linkText(user.getProgrammingLanguage().getValue())).click();
    WebElement acceptAddsCheckbox = driver.findElement(By.id("input_adds"));
    Assert.assertEquals(acceptAddsCheckbox.isSelected(), false);
    acceptAddsCheckbox.click();
    takeScreenShot("User data entered.");
    Assert.assertEquals(driver.getCurrentUrl(), "and-activity://RegisterUserActivity");
    try {
        driver.getTitle();
        Assert.fail("Get title is not supported by SelendroidNativeDriver");
    } catch (WebDriverException e) {
        // expected behavior
    }

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

From source file:org.openqa.selendroid.webviewdrivertests.ElementFindingTest.java

License:Apache License

@Test
public void testShouldfindAnElementBasedOnId() {
    openWebdriverTestPage(HtmlTestData.FORM_PAGE);
    waitFor(pageTitleToBe(driver, "We Leave From Here"), 10, TimeUnit.SECONDS);

    WebElement element = driver.findElement(By.id("checky"));
    Assert.assertEquals(element.isSelected(), false);
}

From source file:org.orcid.api.common.WebDriverHelper.java

License:Open Source License

public String obtainAuthorizationCode(String scopes, String orcid, String userId, String password,
        List<String> inputIdsToCheck, boolean markAsSelected) throws InterruptedException {
    webDriver.get(String.format("%s/oauth/authorize?client_id=%s&response_type=code&scope=%s&redirect_uri=%s",
            webBaseUrl, orcid, scopes, redirectUri));

    // Switch to the login form
    By switchFromLinkLocator = By.id("in-register-switch-form");
    (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS))
            .until(ExpectedConditions.presenceOfElementLocated(switchFromLinkLocator));
    WebElement switchFromLink = webDriver.findElement(switchFromLinkLocator);
    switchFromLink.click();//from   ww  w .  ja va  2 s  .  c  o  m

    // Check the given inputs
    if (inputIdsToCheck != null && !inputIdsToCheck.isEmpty()) {
        for (String id : inputIdsToCheck) {
            By input = By.id(id);
            (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS))
                    .until(ExpectedConditions.presenceOfElementLocated(input));
            WebElement inputElement = webDriver.findElement(input);
            if (markAsSelected) {
                if (!inputElement.isSelected())
                    inputElement.click();
            } else {
                if (inputElement.isSelected())
                    inputElement.click();
            }
        }
    }

    // Fill the form
    By userIdElementLocator = By.id("userId");
    (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS))
            .until(ExpectedConditions.presenceOfElementLocated(userIdElementLocator));
    WebElement userIdElement = webDriver.findElement(userIdElementLocator);
    userIdElement.sendKeys(userId);
    WebElement passwordElement = webDriver.findElement(By.id("password"));
    passwordElement.sendKeys(password);
    WebElement submitButton = webDriver.findElement(By.id("authorize-button"));
    submitButton.click();

    (new WebDriverWait(webDriver, DEFAULT_TIMEOUT_SECONDS)).until(new ExpectedCondition<Boolean>() {
        public Boolean apply(WebDriver d) {
            return d.getTitle().equals("ORCID Playground");
        }
    });
    String currentUrl = webDriver.getCurrentUrl();
    Matcher matcher = AUTHORIZATION_CODE_PATTERN.matcher(currentUrl);
    assertTrue(matcher.find());
    String authorizationCode = matcher.group(1);
    assertNotNull(authorizationCode);
    return authorizationCode;
}