示例#1
0
  /**
   * Paste the current content in the clipboard into a specific target, will wait for ajax refresh
   *
   * @param target the target's label to paste in
   * @return this agent
   * @throws Exception
   */
  public ClipboardAgent pasteContent(String target, boolean isAjaxList) throws Exception {

    String pasteSelectorPrefix = "//h2[contains(text(),'" + target + "')]";
    String pasteSelectorSuffix =
        "/button[contains(@class, 'clipboard') and contains(@title, 'Paste')]";

    // Slots
    String pasteSelector = pasteSelectorPrefix + "/../" + pasteSelectorSuffix;

    WebDriver webDriver = guiAgent.getWebDriver();

    if (webDriver.findElements(By.xpath(pasteSelector)).isEmpty()) {
      // Content lists
      pasteSelector = pasteSelectorPrefix + pasteSelectorSuffix;
    }

    if (webDriver.findElements(By.xpath(pasteSelector)).isEmpty()) {
      pasteSelector = "//fieldset[contains(@class, '" + target + "']/" + pasteSelectorSuffix;
    }

    webDriver.findElement(By.xpath(pasteSelector)).click();

    if (isAjaxList) {
      guiAgent.agentWait().waitForAjaxPageToLoad();
    } else {
      guiAgent.agentWait().waitForPageToLoad();
    }

    return this;
  }