示例#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;
  }
示例#2
0
 /**
  * Returns the size of clipboard
  *
  * @return the size of the clipboard
  */
 public int getClipboardSize() {
   JavascriptExecutor executer = (JavascriptExecutor) guiAgent.getWebDriver();
   Long count =
       (Long)
           executer.executeScript(
               "return window.JSClipboard.getInstance().getLatestClip().isMultiClip == null ? "
                   + "1 : window.JSClipboard.getInstance().getLatestClip().getClipCount();");
   return count.intValue();
 }
示例#3
0
 /**
  * Copy a specific content into the clipboard present in the current frame pane
  *
  * @param contentIdString the content's id to copy
  * @return this agent
  * @throws Exception
  */
 public ClipboardAgent copyContent(String contentIdString) throws Exception {
   WebDriver webDriver = guiAgent.getWebDriver();
   webDriver
       .findElement(
           By.xpath(
               "//button[contains(@class, 'clipboard') and contains(@onclick, '"
                   + contentIdString
                   + "')]"))
       .click();
   return this;
 }
示例#4
0
  /**
   * Copy the current opened content into the clipboard
   *
   * @return this agent
   * @throws Exception
   */
  public ClipboardAgent copyOpenedContent() throws Exception {

    WebDriver webDriver = guiAgent.getWebDriver();
    webDriver
        .findElement(
            By.xpath(
                "//div[contains(@class,'content-info')]/button[contains(@class, 'clipboard')]"))
        .click();

    return this;
  }