Example #1
0
  /**
   * Check visibility of goal templates
   *
   * @param driver
   */
  public void runCheckGoalTemplateVisibility(WebDriver driver) {
    String[] visibilities = this.getExpectedResult().split("\n");
    for (String visibility : visibilities) {
      String[] str_tmp = visibility.split(":");
      String criteria = str_tmp[0];

      String[] goals = str_tmp[1].split(";");
      By by = null;
      // 1. Create goals
      if (criteria.contains("PG")) {
        // check performance goal template
        Navigator.navigate(
            driver,
            Navigator.xmlWebElmtMgr.getNavigationPathList("LearningCenter", "BtnCreatePerfGoal"));

        //				by = By.xpath("//button[descendant::span[text()='"+Labels.Btn_Perf_Goal+"']]");
        ////				Navigator.waitForAjaxElementLoad(driver, by);
        //				//Navigator.explicitWait(1000);
        //				Navigator.waitForAjax(driver, by);
        //				WebDriverUtils.clickButton(driver, by);

      } else if (criteria.contains("DG")) {
        // check development goal template
        Navigator.navigate(
            driver,
            Navigator.xmlWebElmtMgr.getNavigationPathList("LearningCenter", "BtnCreateDevGoal"));
        //				by = By.xpath("//button[descendant::span[text()='"+Labels.Btn_Dev_Goal+"']]");
        ////				Navigator.waitForAjaxElementLoad(driver, by);
        //				//Navigator.explicitWait(1000);
        //				Navigator.waitForAjax(driver, by);
        //				WebDriverUtils.clickButton(driver, by);
      }

      // 2.check goal template visibility
      for (String goal : goals) {
        // 1. Select template
        by = By.xpath("//select[@id='template-name']/option[text()='" + goal + "']");
        // int size = WebDriverUtils.getHowManyByPresntInPage(by);
        if (criteria.contains("invisible")) {
          JUnitAssert.assertTrue(
              WebDriverUtils.getHowManyByPresntInPage(driver, by, false) == 0,
              "Goal is visible:" + goal);
        } else if (criteria.contains("visible")) {
          JUnitAssert.assertTrue(
              WebDriverUtils.getHowManyByPresntInPage(driver, by, true) > 0,
              "Goal is invisible:" + goal);
        }
      }

      // 3. Cancel
      by = By.xpath("//span[text()='" + Labels.Btn_Cancel + "']");
      WebDriverUtils.clickButton(driver, by);
    }
  }
Example #2
0
  /**
   * Can delete the goal if the user is the creator and the goal is not included in the appraisal
   *
   * @param driver
   */
  public void checkCanDelete(WebDriver driver) {
    String row_goal = "//tr[descendant::td/a[text()='" + this.getGoalTitle() + "']]";
    By by = By.xpath(row_goal + "/td[2]/div/div/button");
    // Navigator.explicitWait();
    Navigator.waitForAjax(driver, by);
    //		Navigator.waitForAjaxElementLoad(driver, by);
    WebDriverUtils.mouseOver(driver, by);

    by = By.linkText("Delete");
    // Navigator.explicitWait();
    Navigator.waitForAjax(driver, by);
    //		Navigator.waitForAjaxElementLoad(driver, by);
    int size = WebDriverUtils.getHowManyByPresntInPage(driver, by, true);
    JUnitAssert.assertTrue(size > 0, "Cannot delete" + this.getGoalTitle());

    WebDriverUtils.clickLink(driver, by);
    String delMsg = Labels.Msg_Delete_Dev_Goal.toString();
    if (this instanceof PerformanceGoal) {
      delMsg = Labels.Msg_Delete_Perf_Goal.toString();
    }
    by =
        By.xpath(
            "//div[descendant::div[@id='jMessage' and text()='"
                + delMsg
                + "']]/div/div/button[descendant::span[text()='OK']]");
    WebDriverUtils.clickButton(driver, by);
  }
Example #3
0
  /**
   * Cannot delete the goal if the user is NOT the creator or the goal is included in the appraisal
   *
   * @param driver
   */
  public void checkCannotDelete(WebDriver driver) {
    String row_goal = "//tr[descendant::td/a[text()='" + this.getGoalTitle() + "']]";
    By by = By.xpath(row_goal + "/td[2]/div/div/button");
    // Navigator.explicitWait();
    Navigator.waitForAjax(driver, by);
    //		Navigator.waitForAjaxElementLoad(driver, by);
    WebDriverUtils.mouseOver(driver, by);

    by = By.linkText("Delete");
    int size = WebDriverUtils.getHowManyByPresntInPage(driver, by, false);
    JUnitAssert.assertTrue(size == 0, "Can delete " + this.getGoalTitle());
  }
Example #4
0
 /**
  * Use image comparison techniques to check goal hierarchy
  *
  * @param driver
  */
 public void checkGoalHierarchy(WebDriver driver) {
   // 1. Sikuli: Image-based comparison
   String screenshotFile = this.getGoalHierarchyFile();
   boolean exist = SikuliUtils.screenshotExistInWin(screenshotFile);
   JUnitAssert.assertTrue(exist, "Cannot find image:" + screenshotFile);
 }