Exemplo n.º 1
0
  @Override
  public AbsPage zTreeItem(Action action, Button option, IItem folder) throws HarnessException {

    tracer.trace("Click " + action + " then " + option + " on folder " + folder.getName());

    // Validate the arguments
    if ((action == null) || (option == null) || (folder == null)) {
      throw new HarnessException("Must define an action, option, and addressbook");
    }

    if (folder instanceof FolderMountpointItem) {
      return (zTreeItem(action, option, (FolderMountpointItem) folder));
    } else if (folder instanceof SavedSearchFolderItem) {
      return (zTreeItem(action, option, (SavedSearchFolderItem) folder));
      // } else if ( folder instanceof ZimletItem ) {
      //	return (zTreeItem(action, option, (ZimletItem)folder));
    } else if (folder instanceof TagItem) {
      return (zTreeItem(action, option, (TagItem) folder));
    } else if (folder instanceof FolderItem) { // FolderItem needs to go last
      return (zTreeItem(action, option, (FolderItem) folder));
    }

    throw new HarnessException(
        "Must use TagItem FolderItem or SavedSearchFolderItem or ZimletItem as argument, but was "
            + folder.getClass());
  }
  @Override
  public void zFill(IItem item) throws HarnessException {
    logger.info(FormAddZimbraAccount.class.getCanonicalName() + ".fill(IItem)");
    logger.info(item.prettyPrint());

    // Make sure the item is a DesktopAccountItem
    if (!(item instanceof DesktopAccountItem)) {
      throw new HarnessException("Invalid item type - must be DesktopAccountItem");
    }

    // Convert object to ContactGroupItem
    DesktopAccountItem desktopAccountItem = (DesktopAccountItem) item;

    // Fill out the form
    if (desktopAccountItem.accountName != null && !desktopAccountItem.accountName.equals("")) {
      sType(Locators.zAccountNameField, desktopAccountItem.accountName);
    }

    if (desktopAccountItem.emailAddress != null && !desktopAccountItem.emailAddress.equals("")) {
      sType(Locators.zEmailAddressField, desktopAccountItem.emailAddress);
    }

    if (desktopAccountItem.incomingServer != null
        && !desktopAccountItem.incomingServer.equals("")) {
      sType(Locators.zIncomingServerField, desktopAccountItem.incomingServer);
    }

    if (desktopAccountItem.password != null && !desktopAccountItem.password.equals("")) {
      sType(Locators.zPasswordField, desktopAccountItem.password);
    }

    if (desktopAccountItem.ssl) {
      sClick(Locators.zSecuritySSLRadioButton);
    } else {
      sClick(Locators.zSecurityNoneRadioButton);
    }

    if (desktopAccountItem.port != null && !desktopAccountItem.port.equals("")) {
      if (!sGetText(Locators.zPortField).equals(desktopAccountItem.port)) {
        zClick(Locators.zEditPortLink);
        sType(Locators.zPortField, desktopAccountItem.port);
      } else {
        logger.debug("Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }
  }
Exemplo n.º 3
0
  public AbsPage zTreeItem(Action action, IItem item, boolean isRowAdded) throws HarnessException {

    tracer.trace("Click " + action + " on folder " + item.getName());

    String treeItemLocator = Locators.briefcaseTreeView + "]";

    AbsPage page = zTreeItem(action, item);

    zWaitForElementPresent(treeItemLocator);

    String listItemLocator = "css=div[id^=zl__BDLV][class=DwtListView-Rows]";

    if (isRowAdded) listItemLocator += ">div[id^=zli__BDLV][class^=Row]";

    zWaitForElementPresent(listItemLocator);

    return page;
  }
Exemplo n.º 4
0
  @Override
  public void zFill(IItem item) throws HarnessException {
    logger.info(FormAddImapAccount.class.getCanonicalName() + ".fill(IItem)");
    logger.info(item.prettyPrint());

    // Make sure the item is a DesktopAccountItem
    if (!(item instanceof DesktopAccountItem)) {
      throw new HarnessException("Invalid item type - must be DesktopAccountItem");
    }

    // Convert object to ContactGroupItem
    DesktopAccountItem desktopAccountItem = (DesktopAccountItem) item;

    // Fill out the form
    if (desktopAccountItem.accountName != null && !desktopAccountItem.accountName.equals("")) {
      sType(Locators.zAccountNameField, desktopAccountItem.accountName);
    }

    if (desktopAccountItem.emailAddress != null && !desktopAccountItem.emailAddress.equals("")) {
      sType(Locators.zEmailAddressField, desktopAccountItem.emailAddress);
    }

    if (desktopAccountItem.fullName != null && !desktopAccountItem.fullName.equals("")) {
      sType(Locators.zFullNameField, desktopAccountItem.fullName);
    }

    if (desktopAccountItem.receivingUsernname != null
        && !desktopAccountItem.receivingUsernname.equals("")) {
      sType(Locators.zReceivingUserNameField, desktopAccountItem.receivingUsernname);
    }

    if (desktopAccountItem.receivingPassword != null
        && !desktopAccountItem.receivingPassword.equals("")) {
      sType(Locators.zReceivingPasswordField, desktopAccountItem.receivingPassword);
    }

    if (desktopAccountItem.receivingIncomingServer != null
        && !desktopAccountItem.receivingIncomingServer.equals("")) {
      sType(Locators.zReceivingServerField, desktopAccountItem.receivingIncomingServer);
    }

    if (desktopAccountItem.receivingPassword != null
        && !desktopAccountItem.receivingPassword.equals("")) {
      sType(Locators.zReceivingPasswordField, desktopAccountItem.receivingPassword);
    }

    if (desktopAccountItem.receivingSecurityType != null) {
      String radioButtonLocator = null;
      switch (desktopAccountItem.receivingSecurityType) {
        case NONE:
          radioButtonLocator = Locators.zSecurityNoneRadioButton;
          break;
        case SSL:
          radioButtonLocator = Locators.zSecuritySSLRadioButton;
          break;
        case TLS:
          radioButtonLocator = Locators.zSecurityTLSRadioButton;
          break;
        case TLS_IF_AVAILABLE:
          radioButtonLocator = Locators.zSecurityTLSIfAvailableRadioButton;
          break;
        default:
          throw new HarnessException(
              "Unuspported receivingSecurityType: " + desktopAccountItem.receivingSecurityType);
      }

      sClick(radioButtonLocator);
    }

    if (desktopAccountItem.receivingPort != null && !desktopAccountItem.receivingPort.equals("")) {

      if (!sGetText(Locators.zReceivingPortField).equals(desktopAccountItem.receivingPort)) {
        zClick(Locators.zEditReceivingPortLink);
        sType(Locators.zReceivingPortField, desktopAccountItem.receivingPort);
      } else {
        logger.debug(
            "Receiving Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }

    if (desktopAccountItem.sendingSmtpServer != null
        && !desktopAccountItem.sendingSmtpServer.equals("")) {
      sType(Locators.zSendingServerField, desktopAccountItem.sendingSmtpServer);
    }

    if (desktopAccountItem.sendingThroughSsl) {
      sCheck(Locators.zSendingSSLCheckbox);
    } else {
      sUncheck(Locators.zSendingSSLCheckbox);
    }

    if (desktopAccountItem.sendingPort != null && !desktopAccountItem.sendingPort.equals("")) {

      if (!sGetText(Locators.zSendingPortField).equals(desktopAccountItem.sendingPort)) {
        zClick(Locators.zEditSendingPortLink);
        sType(Locators.zSendingPortField, desktopAccountItem.sendingPort);
      } else {
        logger.debug(
            "Sending Port is already the same as the new one," + " thus no need to change it");
        // Fall through
      }
    }

    if (desktopAccountItem.sendingUserName != null || desktopAccountItem.sendingPassword != null) {
      sCheck(Locators.zUseAuthCheckbox);
      GeneralUtility.waitForElementPresent(this, Locators.zSendingUserNameField);
      if (!sGetText(Locators.zSendingUserNameField).equals(desktopAccountItem.sendingUserName)) {
        sType(Locators.zSendingUserNameField, desktopAccountItem.sendingUserName);
      }

      if (!sGetText(Locators.zSendingPasswordField).equals(desktopAccountItem.sendingPassword)) {
        sType(Locators.zSendingPasswordField, desktopAccountItem.sendingPassword);
      }
    }
  }
Exemplo n.º 5
0
  @Override
  public AbsPage zTreeItem(Action action, Button option, IItem item) throws HarnessException {
    // Validate the arguments
    if ((action == null) || (option == null) || (item == null)) {
      throw new HarnessException(
          "zTreeItem(Action, Button, IItem): Must define an action, option, and item");
    }

    logger.info(
        myPageName() + " zTreeItem(" + action + ", " + option + ", " + item.getName() + ")");

    tracer.trace("Click " + action + " then " + option + " on item " + item.getName());

    AbsPage page = null;
    String actionLocator = null;
    String optionLocator = null;

    if (item instanceof TagItem) {
      actionLocator =
          "css=td[id^=zti__main_Briefcase__]:contains(" + ((TagItem) item).getName() + ")";
    } else if (item instanceof FolderItem) {
      actionLocator =
          "css=td[id^=zti__main_Briefcase__" + ((FolderItem) item).getId() + "_textCell]";
    } else {
      throw new HarnessException("Must use IItem as argument, but was " + item.getClass());
    }

    zWaitForElementVisible(actionLocator);

    if (action == Action.A_RIGHTCLICK) {
      this.zRightClickAt(actionLocator, "0,0");
    } else {
      throw new HarnessException("implement me! " + action + ": not implemented");
    }

    if (option == Button.B_TREE_NEWTAG) {

      optionLocator = Locators.zNewTagTreeMenuItem;

      page = new DialogTag(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else if (option == Button.B_TREE_RENAMETAG) {

      optionLocator = Locators.zRenameTagTreeMenuItem;

      page = new DialogRenameTag(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
    } else if (option == Button.B_TREE_DELETE) {

      optionLocator = Locators.zDeleteTreeMenuItem;

      if (item instanceof TagItem) {
        page =
            new DialogWarning(
                DialogWarning.DialogWarningID.DeleteTagWarningMessage,
                MyApplication,
                ((AppAjaxClient) MyApplication).zPageBriefcase);
      }
    } else if (option == Button.B_TREE_NEWFOLDER) {

      optionLocator = Locators.zNewFolderTreeMenuItem;

      page =
          new DialogCreateBriefcaseFolder(
              MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else if (option == Button.B_TREE_EDIT_PROPERTIES) {

      optionLocator = Locators.zEditPropertiesTreeMenuItem;

      page =
          new DialogEditProperties(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);

    } else {
      throw new HarnessException("button " + option + " not yet implemented");
    }

    this.zWaitForBusyOverlay();

    zWaitForElementVisible(optionLocator);

    // Default behavior. Click the locator
    zClickAt(optionLocator, "");

    // If there is a busy overlay, wait for that to finish
    this.zWaitForBusyOverlay();

    if (page != null) {
      // Wait for the page to become active, if it was specified
      page.zWaitForActive();
    }
    return (page);
  }
Exemplo n.º 6
0
  @Override
  public AbsPage zTreeItem(Action action, IItem item) throws HarnessException {
    // Validate the arguments
    if ((action == null) || (item == null)) {
      throw new HarnessException("zTreeItem(Action, IItem): Must define an action, and item");
    }
    logger.info(myPageName() + " zTreeItem(" + action + ", " + item.getName() + ")");

    tracer.trace("Click " + action + " on item " + item.getName());

    AbsPage page = null;
    String locator = null;

    if (item instanceof TagItem) {
      locator = "css=td[id^=zti__main_Briefcase__]:contains(" + ((TagItem) item).getName() + ")";
    } else if (item instanceof FolderItem) {
      locator = Locators.briefcaseTreeView + ((FolderItem) item).getId() + "_imageCell]";

    } else if (item instanceof LinkItem) {
      page = new DialogFindShares(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
      if (ZimbraSeleniumProperties.isWebDriver()) {
        clickBy(By.id("ztih__main_Briefcase__BRIEFCASE"), By.linkText("Find Shares..."));
        return page;
      } else {
        locator = "css=div[id=ztih__main_Briefcase__BRIEFCASE] a[id$=_addshare_link]";
        page = new DialogFindShares(MyApplication, ((AppAjaxClient) MyApplication).zPageBriefcase);
      }

      if (!this.sIsElementPresent(locator)) {
        throw new HarnessException("Unable to locate link in the tree " + locator);
      }

      this.sClickAt(locator, "0,0");

      zWaitForBusyOverlay();

      return page;

    } else {
      throw new HarnessException("Must use IItem as argument, but was " + item.getClass());
    }

    if (action == Action.A_LEFTCLICK) {

      zWaitForBusyOverlay();

      // FALL THROUGH
    } else if (action == Action.A_RIGHTCLICK) {

      if (!this.sIsElementPresent(locator))
        throw new HarnessException("Unable to locate folder in the tree " + locator);

      // Select the folder
      this.zRightClickAt(locator, "0,0");

      // return a context menu
      return (new ContextMenu(MyApplication));
    } else {
      throw new HarnessException("Action " + action + " not yet implemented");
    }

    if (!this.sIsElementPresent(locator))
      throw new HarnessException("Unable to locate folder in the tree " + locator);

    // Default behavior. Click the locator
    zClickAt(locator, "0,0");

    // If there is a busy overlay, wait for that to finish
    zWaitForBusyOverlay();

    return (page);
  }