/**
  * Method to switch to Google Drive window
  *
  * @param drone WebDrone
  * @return EditGoogleDocsPage
  */
 private static EditInGoogleDocsPage switchToGoogleWindow(WebDrone drone) {
   Set<String> setWindowHandles = drone.getWindowHandles();
   int retry = 0;
   while (setWindowHandles.size() < 2) {
     webDriverWait(drone, 3000);
     retry++;
     setWindowHandles = drone.getWindowHandles();
     if (retry == 3) {
       throw new PageOperationException("Google doc isn't opened in new window for Editing");
     }
   }
   String[] windowHandles = setWindowHandles.toArray(new String[setWindowHandles.size()]);
   drone.switchToWindow(windowHandles[1]);
   return FactorySharePage.resolvePage(drone).render();
 }
 /**
  * Discarding the changes made in google doc.
  *
  * @param drone WebDrone
  * @return SharePage
  */
 public static HtmlPage discardGoogleDocsChanges(WebDrone drone) {
   EditInGoogleDocsPage googleDocsPage = ShareUser.getSharePage(drone).render();
   if (isGoogleDocsV3) {
     String docTitle = googleDocsPage.getDocumentTitle();
     closeAndSwitchToShare(drone);
     HtmlPage currentPage = FactorySharePage.resolvePage(drone);
     if (currentPage instanceof DocumentLibraryPage) {
       ((DocumentLibraryPage) currentPage)
           .getFileDirectoryInfo(docTitle)
           .selectCancelEditingInGoogleDocs()
           .render();
     } else if (currentPage instanceof DocumentDetailsPage) {
       ((DocumentDetailsPage) currentPage).clickCancelEditingInGoogleDocs().render();
     }
     HtmlPage thePage = FactorySharePage.resolvePage(drone).render();
     if (thePage instanceof SharePopup) {
       ((SharePopup) thePage).clickYes();
       drone.waitUntilElementDeletedFromDom(
           By.cssSelector("span[class='message']"), SECONDS.convert(maxWaitTime, MILLISECONDS));
     }
   } else {
     GoogleDocsDiscardChanges googleDocsDiscardChanges = googleDocsPage.selectDiscard().render();
     return googleDocsDiscardChanges.clickOkButton().render();
   }
   return FactorySharePage.resolvePage(drone).render();
 }
 /**
  * Discarding the changes made in google doc.
  *
  * @param filename String
  * @return SharePage
  */
 public static GoogleSignUpPage openSignUpPage(WebDrone driver, String filename) {
   DocumentLibraryPage docLibPage = driver.getCurrentPage().render();
   GoogleDocsAuthorisation googleAuth =
       docLibPage.getFileDirectoryInfo(filename).selectEditInGoogleDocs().render();
   Assert.assertTrue(googleAuth.isAuthorisationDisplayed());
   return googleAuth.submitAuth().render();
 }
  public static RepositoryPage openUserFromUserHomesFolderOfRepository(
      WebDrone drone, String usrName) {
    String url = drone.getCurrentUrl();
    // http://127.0.0.1:8081/share  /page/repository#filter=path|%2FUser%2520Homes%2F
    // userEnterprise42-5405%40freetht1.test-1  |&page=1
    String target =
        url.substring(0, url.indexOf("/page/"))
            + "/page/repository#filter=path|%2FUser%2520Homes%2F"
            + StringUtils.replace(usrName, "@", "%40")
            + "|&page=1";

    drone.navigateTo(target);
    drone.waitForPageLoad(maxWaitTime);
    RepositoryPage repoPage = (RepositoryPage) ShareUser.getSharePage(drone);

    return repoPage.render();
  }
 /**
  * Put search text into search input
  *
  * @param - String
  * @return - TrashCanPage as response
  */
 public static WebElement searchInput(WebDrone drone) {
   return drone.find(TRASHCAN_SEARCH_INPUT);
   //        inputField.clear();
   //        inputField.sendKeys(searchText);
   //        drone.find(TRASHCAN_SEARCH_BUTTON).click();
   //        drone.waitUntilElementDisappears(PAGE_LOADING, 1);
   //        return drone.getCurrentPage();
 }
 /**
  * This method is used to delete the given user profile.
  *
  * @param testUser String
  * @param drone WebDrone
  * @return {@link UserSearchPage}
  */
 protected UserSearchPage deleteUser(WebDrone drone, String testUser) {
   if (isAlfrescoVersionCloud(drone)) {
     throw new UnsupportedOperationException("Delete user is available in cloud");
   }
   DashBoardPage dashBoard = drone.getCurrentPage().render();
   UserSearchPage page = dashBoard.getNav().getUsersPage().render();
   page = page.searchFor(testUser).render();
   UserProfilePage userProfile = page.clickOnUser(testUser).render();
   return userProfile.deleteUser().render();
 }
Esempio n. 7
0
  /**
   * Method to get LinkId
   *
   * @param drone
   * @param siteName
   * @param linkTitle
   * @return String
   */
  public static String getLinkId(WebDrone drone, String siteName, String linkTitle) {
    try {

      SiteDashboardPage site = ShareUser.openSiteDashboard(drone, siteName).render();
      LinksPage linksPage = site.getSiteNav().selectLinksPage();
      linksPage.clickLink(linkTitle);
      WebElement element = drone.findAndWait(By.xpath(LINK_TITLE_PREVIEW));
      String linkId = element.getAttribute("href").split("[?=]+")[2];
      return linkId;
    } catch (NoSuchElementException ex) {
      throw new NoSuchElementException("Element not found", ex);
    }
  }
Esempio n. 8
0
 /** Constructor. */
 protected SiteNavigation(WebDrone drone) {
   super(drone);
   siteMembersCSS = drone.getElement("site.members");
   documentLibLink =
       getAlfrescoVersion().isDojoSupported()
           ? LABEL_DOCUMENTLIBRARY_PLACEHOLDER
           : String.format(SITE_LINK_NAV_PLACEHOLER, 3);
   customizeDashboardLink =
       getAlfrescoVersion().isDojoSupported()
           ? By.id("HEADER_CUSTOMIZE_SITE_DASHBOARD")
           : CUSTOMISE_DASHBOARD_BTN;
   moreButton =
       getAlfrescoVersion().isDojoSupported()
           ? By.cssSelector("span.alf-menu-arrow")
           : By.cssSelector("button[id$='_default-more-button']");
 }
  /**
   * Saves the google doc with the given comments as minor or major version.
   *
   * @param drone WebDrone
   * @param comments String
   * @param isMinorVersion boolean
   * @return GoogleDocsUpdateFilePage
   */
  public static GoogleDocsUpdateFilePage saveGoogleDocWithVersionAndComment(
      WebDrone drone, String comments, boolean isMinorVersion) {
    EditInGoogleDocsPage googleDocsPage = drone.getCurrentPage().render();
    GoogleDocsUpdateFilePage googleUpdateFile = googleDocsPage.selectSaveToAlfresco().render();

    if (isMinorVersion) {
      googleUpdateFile.selectMinorVersionChange();
    } else {
      googleUpdateFile.selectMajorVersionChange();
    }

    if (!StringUtils.isEmpty(comments)) {
      googleUpdateFile.setComment(comments);
    }

    return googleUpdateFile;
  }
 /**
  * This method provides the sign in page to log into google docs.
  *
  * @param googleAuth GoogleDocsAuthorisation
  * @return EditInGoogleDocsPage
  */
 public static EditInGoogleDocsPage signInGoogleDocs(
     WebDrone driver, GoogleDocsAuthorisation googleAuth) throws InterruptedException {
   int i = 0;
   GoogleSignUpPage signUpPage = googleAuth.submitAuth().render();
   signUpPage.signUp(googleUserName, googlePassword);
   if (isGoogleDocsV3) {
     switchToGoogleWindow(driver);
   }
   while (!(driver.getCurrentPage() instanceof EditInGoogleDocsPage)) {
     webDriverWait(driver, 10000);
     i++;
     if (i == retrySearchCount) {
       break;
     }
   }
   return FactorySharePage.resolvePage(driver).render();
 }
 /**
  * Method to close Google Drive window and switch to Alfresco
  *
  * @param drone WebDrone
  * @return SharePage
  */
 private static SharePage closeAndSwitchToShare(WebDrone drone) {
   Set<String> setWindowHandles = drone.getWindowHandles();
   drone.closeWindow();
   drone.switchToWindow(setWindowHandles.toArray(new String[setWindowHandles.size()])[0]);
   return FactorySharePage.resolvePage(drone).render();
 }