/** * This method is used to create content with name, title and description. User should be logged * in * * @param drone * @param contentDetails * @param contentType * @return {@link RepositoryPage} * @throws Exception */ public static RepositoryPage createContentInFolder( WebDrone drone, ContentDetails contentDetails, ContentType contentType, String... folderPath) throws Exception { // Open Folder in repository Library RepositoryPage repositoryPage = navigateFoldersInRepositoryPage(drone, folderPath); DocumentDetailsPage detailsPage = null; try { CreatePlainTextContentPage contentPage = repositoryPage.getNavigation().selectCreateContent(contentType).render(); detailsPage = contentPage.create(contentDetails).render(); repositoryPage = detailsPage.navigateToFolderInRepositoryPage().render(); } catch (Exception e) { throw new SkipException("Error in creating content." + e); } return repositoryPage; }
/** * Creates files in site's document library * * @param numberOfFiles * @param siteName * @throws Exception */ public static void createFilesInSite( WebDrone drone, String testName, int numberOfFiles, String siteName) throws Exception { // Create Files for (int i = 0; i <= numberOfFiles - 1; i++) { DocumentLibraryPage documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName); ContentDetails contentDetails = new ContentDetails(); String fileName = getFileName(testName + "_" + i + "." + "txt"); contentDetails.setName(fileName); contentDetails.setTitle(testName + " title"); contentDetails.setDescription(testName + " description"); contentDetails.setContent(testName + " content"); CreatePlainTextContentPage contentPage = documentLibraryPage.getNavigation().selectCreateContent(ContentType.PLAINTEXT).render(); contentPage.create(contentDetails).render(); } }
/** * This method is used to create content with name, title and description. User should be logged * in * * @param drone * @param contentDetails * @param contentType * @return {@link RepositoryPage} * @throws Exception */ public static HtmlPage createContentInFolderWithValidation( WebDrone drone, ContentDetails contentDetails, ContentType contentType, String... folderPath) throws Exception { // Open Folder in repository Library RepositoryPage repositoryPage = navigateFoldersInRepositoryPage(drone, folderPath); try { CreatePlainTextContentPage contentPage = repositoryPage.getNavigation().selectCreateContent(contentType).render(); HtmlPage page = contentPage.createWithValidation(contentDetails).render(); if (page instanceof DocumentDetailsPage) { DocumentDetailsPage detailsPage = page.render(); repositoryPage = detailsPage.navigateToFolderInRepositoryPage().render(); return repositoryPage; } return page; } catch (Exception e) { throw new SkipException("Error in creating content." + e.getMessage()); } }
/** * Creates files in a folder in site's document library * * @param numberOfFiles * @param siteName * @param siteNumber * @throws Exception */ public static void createFilesInSiteFolder( WebDrone drone, String testName, int numberOfFiles, String siteName, int siteNumber, String rule) throws Exception { // Create folder String folderName = getFileName(testName + "_" + siteNumber); DocumentLibraryPage documentLibraryPage = ShareUserSitePage.createFolder(drone, folderName, folderName); // create rule if rule is set if (MOVE_RULE.equalsIgnoreCase(rule)) { FolderRulesPage folderRulesPage = documentLibraryPage.getFileDirectoryInfo(folderName).selectManageRules().render(); Assert.assertTrue(folderRulesPage.isPageCorrect(folderName)); CreateRulePage createRulePage = folderRulesPage.openCreateRulePage().render(); createRulePage.fillNameField("New Move Rule Name"); createRulePage.fillDescriptionField("New Move Rule Description"); ActionSelectorEnterpImpl actionSelectorEnterpImpl = createRulePage.getActionOptionsObj(); // move rule actionSelectorEnterpImpl.selectMove(siteName, "Documents"); FolderRulesPageWithRules folderRulesPageWithRules = createRulePage.clickCreate().render(); Assert.assertTrue(folderRulesPageWithRules.isPageCorrect(folderName)); documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName); } else if (COPY_RULE.equalsIgnoreCase(rule)) { FolderRulesPage folderRulesPage = documentLibraryPage.getFileDirectoryInfo(folderName).selectManageRules().render(); Assert.assertTrue(folderRulesPage.isPageCorrect(folderName)); CreateRulePage createRulePage = folderRulesPage.openCreateRulePage().render(); createRulePage.fillNameField("New Copy and Transform Rule Name"); createRulePage.fillDescriptionField("New Copy and Transform Rule Description"); ActionSelectorEnterpImpl actionSelectorEnterpImpl = createRulePage.getActionOptionsObj(); // copy rule actionSelectorEnterpImpl.selectTransformAndCopy("XML", siteName, "Documents"); FolderRulesPageWithRules folderRulesPageWithRules = createRulePage.clickCreate().render(); Assert.assertTrue(folderRulesPageWithRules.isPageCorrect(folderName)); documentLibraryPage = ShareUser.openSitesDocumentLibrary(drone, siteName); } documentLibraryPage.selectFolder(folderName).render(); // Create Files for (int i = 0; i <= numberOfFiles - 1; i++) { ContentDetails contentDetails = new ContentDetails(); String fileName = getFileName(testName + "_" + i + "." + "txt"); contentDetails.setName(fileName); contentDetails.setTitle(testName + " title"); contentDetails.setDescription(testName + " description"); contentDetails.setContent(testName + " content"); CreatePlainTextContentPage contentPage = documentLibraryPage.getNavigation().selectCreateContent(ContentType.PLAINTEXT).render(); contentPage.create(contentDetails).render(); ShareUserSitePage.navigateToFolder(drone, folderName); } }