Ejemplo n.º 1
0
  /**
   * Create a file document and manipulate coverage and subjects fields based on select2 attributes.
   *
   * @throws Exception
   * @since 5.7.3
   */
  @Test
  public void testSelect2Edit() throws Exception {
    login(TEST_USERNAME, TEST_PASSWORD);
    open(String.format(NXDOC_URL_FORMAT, fileId));

    FileDocumentBasePage filePage = asPage(FileDocumentBasePage.class);
    EditTabSubPage editTabSubPage = filePage.getEditTab();

    Select2WidgetElement subjectsWidget =
        new Select2WidgetElement(
            driver,
            driver.findElement(
                By.xpath("//*[@id='s2id_document_edit:nxl_dublincore:nxw_subjects_1_select2']")),
            true);
    subjectsWidget.selectValues(SUBJECTS);

    Select2WidgetElement coverageWidget =
        new Select2WidgetElement(
            driver,
            driver.findElement(
                By.xpath("//*[@id='s2id_document_edit:nxl_dublincore:nxw_coverage_1_select2']")),
            false);
    coverageWidget.selectValue(COVERAGE);

    editTabSubPage.save();

    editTabSubPage = filePage.getEditTab();

    WebElement savedCoverage = driver.findElement(By.xpath(S2_COVERAGE_FIELD_XPATH));
    final String text = savedCoverage.getText();
    assertNotNull(text);
    assertTrue(text.endsWith(COVERAGE));

    List<WebElement> savedSubjects =
        driver.findElements(
            By.xpath(
                "//*[@id='s2id_document_edit:nxl_dublincore:nxw_subjects_1_select2']/ul/li/div"));
    assertEquals(savedSubjects.size(), SUBJECTS.length);

    // Remove the second subject
    Locator.findElementWaitUntilEnabledAndClick(
        By.xpath("//*[@id='s2id_document_edit:nxl_dublincore:nxw_subjects_1_select2']/ul/li[2]/a"));

    // We need to do this because select2 take a little while to write in
    // the form that an entry has been deleted
    Thread.sleep(250);

    editTabSubPage.save();

    filePage.getEditTab();

    // Make sure we have one subject removed
    savedSubjects =
        driver.findElements(
            By.xpath(
                "//*[@id='s2id_document_edit:nxl_dublincore:nxw_subjects_1_select2']/ul/li/div"));
    assertEquals(savedSubjects.size(), SUBJECTS.length - 1);

    logout();
  }
Ejemplo n.º 2
0
  /**
   * Inits the repository with a File document and makes two versions of it.
   *
   * @param currentPage the current page
   * @return the created File document page
   * @throws Exception if initializing repository fails
   */
  @Override
  protected DocumentBasePage initRepository(DocumentBasePage currentPage) throws Exception {

    // Create test Workspace
    DocumentBasePage workspacePage = super.initRepository(currentPage);

    // Create test File
    FileDocumentBasePage filePage =
        createFile(workspacePage, "Test file", "Test File description", false, null, null, null);

    // Create version 1.0 of the File
    filePage
        .getEditTab()
        .edit("Test file: modif 1", null, EditTabSubPage.MAJOR_VERSION_INCREMENT_VALUE);

    // Create version 2.0 of the File
    filePage
        .getEditTab()
        .edit("Test file: modif 2", null, EditTabSubPage.MAJOR_VERSION_INCREMENT_VALUE);

    return filePage;
  }