Esempio n. 1
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);
  }