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.xwiki.test.ui.administration.elements.TemplateProviderInlinePage.java

License:Open Source License

/**
 * Sets all spaces besides the ones passed in the list.
 * /*from  w ww. ja v  a 2  s . c  om*/
 * @param spaces the spaces to exclude
 */
public void excludeSpaces(List<String> spaces) {
    List<String> selectedSpaces = getSelectedSpaces();
    // if there is no selected space or all the selected spaces will be unchecked upon excluding them
    if (selectedSpaces.size() == 0 || spaces.containsAll(selectedSpaces)) {
        // go through all the spaces and select them, and unselect the ones in the list to exclude
        for (WebElement input : getSpacesInput()) {
            // prevent checking the hidden fields with empty value
            if (!input.isSelected() && input.getValue().length() > 0) {
                input.toggle();
            }
            if (spaces.contains(input.getValue())) {
                input.toggle();
            }
        }
    } else {
        // go through the spaces and make sure the exclude list is unselected
        for (WebElement input : getSpacesInput()) {
            if (spaces.contains(input.getValue()) && input.isSelected()) {
                input.toggle();
            }
        }
    }
}

From source file:org.xwiki.test.ui.administration.ImportTest.java

License:Open Source License

@Test
public void testImportAsBackup() throws IOException {
    URL fileUrl = this.getClass().getResource("/administration/" + BACKUP_PACKAGE);

    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(BACKUP_PACKAGE);

    WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
    Assert.assertTrue(importAsBackup.isSelected());

    this.sectionPage.importPackage();

    ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");

    // Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
    // will race for completion. Let's wait for comments first.
    importedPage.openCommentsDocExtraPane();
    HistoryTab history = importedPage.openHistoryDocExtraPane();

    Assert.assertEquals("JohnDoe", history.getCurrentAuthor());
}

From source file:org.xwiki.test.ui.administration.ImportTest.java

License:Open Source License

@Test
public void testImportWhenImportAsBackupIsNotSelected() throws IOException {
    URL fileUrl = this.getClass().getResource("/administration/" + BACKUP_PACKAGE);

    this.sectionPage.attachPackage(fileUrl);
    this.sectionPage.selectPackage(BACKUP_PACKAGE);

    WebElement importAsBackup = getDriver().findElement(By.name("importAsBackup"));
    importAsBackup.click();//  www.  j av  a2 s.  c  om
    Assert.assertFalse(importAsBackup.isSelected());

    this.sectionPage.importPackage();

    ViewPage importedPage = this.sectionPage.clickImportedPage("Main.TestPage");

    // Since the page by default opens the comments pane, if we instantly click on the history, the two tabs
    // will race for completion. Let's wait for comments first.
    importedPage.openCommentsDocExtraPane();
    HistoryTab history = importedPage.openHistoryDocExtraPane();

    Assert.assertEquals("Administrator", history.getCurrentAuthor());
}

From source file:org.xwiki.test.ui.annotations.elements.AnnotationsPane.java

License:Open Source License

/**
 * Checks the "Show Annotations" check box.
 *///from www .  ja v a2  s  .  c o m
public void showAnnotations() {
    if (this.isVisible == false) {
        Assert.fail("Annotation Pane is hidden");
    }
    waitUntilElementIsVisible(By.className("annotationsettings"));
    WebElement checkBox = getDriver().findElement(By.id("annotationsdisplay"));
    if (checkBox.isSelected() == false) {
        checkBox.setSelected();
    }
}

From source file:org.xwiki.test.ui.annotations.elements.AnnotationsPane.java

License:Open Source License

/**
 * Un-Checks the "Show Annotations" checkbox.
 *///from  ww w . ja v a  2  s  . co  m
public void hideAnnotations() {
    if (this.isVisible == false) {
        Assert.fail("Annotation Pane is hidden");
    }
    waitUntilElementIsVisible(By.className("annotationsettings"));
    WebElement checkBox = getDriver().findElement(By.id("annotationsdisplay"));
    if (checkBox.isSelected() == true) {
        checkBox.toggle();
    }
}

From source file:org.xwiki.test.ui.framework.elements.FormElement.java

License:Open Source License

public void setCheckBox(WebElement checkBoxElement, boolean checked) {
    int x = 0;//w  w w . j  av a  2s.co m
    while (checkBoxElement.isSelected() != checked) {
        checkBoxElement.toggle();
        if (x == 100) {
            throw new WebDriverException(
                    "Unable to set checkbox at " + checkBoxElement.getAttribute("name") + " to " + checked);
        }
        x++;
    }
}

From source file:org.xwiki.test.ui.po.FormElement.java

License:Open Source License

public void setCheckBox(WebElement checkBoxElement, boolean checked) {
    int x = 0;//from  ww w  .j  a v a2s  .c  o m
    while (checkBoxElement.isSelected() != checked) {
        checkBoxElement.click();
        if (x == 100) {
            throw new WebDriverException(
                    "Unable to set checkbox at " + checkBoxElement.getAttribute("name") + " to " + checked);
        }
        x++;
    }
}

From source file:org.zanata.page.groups.VersionGroupsPage.java

License:Open Source License

public VersionGroupsPage toggleArchived(final boolean show) {
    WebElement showArchived = readyElement(toggleArchived);
    if (show != showArchived.isSelected()) {
        showArchived.click();/*  w  w  w .java 2  s  . com*/
    }
    waitForAMoment().until(new Predicate<WebDriver>() {
        @Override
        public boolean apply(WebDriver input) {
            return readyElement(groupTable).findElements(archiveLink).isEmpty() == !show;
        }
    });
    return new VersionGroupsPage(getDriver());
}

From source file:org.zanata.page.projects.ProjectsPage.java

License:Open Source License

public ProjectsPage setActiveFilterEnabled(boolean enabled) {
    log.info("Click to set Active filter enabled to {}", enabled);
    WebElement activeCheckbox = readyElement(activeCheckBox);
    if (activeCheckbox.isSelected() != enabled) {
        activeCheckbox.click();//from w w w.  j a  v a  2  s. c  o m
    }
    return new ProjectsPage(getDriver());
}

From source file:org.zanata.page.projects.ProjectsPage.java

License:Open Source License

public ProjectsPage setReadOnlyFilterEnabled(final boolean enabled) {
    log.info("Click to set Read-only filter enabled to {}", enabled);
    WebElement readOnlyCheckbox = readyElement(readOnlyCheckBox);
    if (readOnlyCheckbox.isSelected() != enabled) {
        readOnlyCheckbox.click();//  w  ww  .  j a v  a  2 s  .  c  o m
    }
    return new ProjectsPage(getDriver());
}