/** * Add goal progress tracks * * @param driver * @param objs: a set of GoalProgress */ public void runAddTrack(WebDriver driver, ArrayList<TestObject> objs) { Navigator.navigate( driver, Navigator.xmlWebElmtMgr.getNavigationPathList("LearningCenter", "MyGoals")); By by = By.xpath("//a[descendant::span[text()='" + Labels.Link_My_Perf_Goal + "']]"); if (this instanceof DevelopmentGoal) { by = By.xpath("//a[descendant::span[text()='" + Labels.Link_My_Dev_Goal + "']]"); } // Navigator.explicitWait(1000); Navigator.waitForAjax(driver, by); // Navigator.waitForAjaxElementLoad(driver, by); WebDriverUtils.clickButton(driver, by); by = By.linkText(this.getGoalTitle()); WebDriverUtils.clickLink(driver, by); by = By.id("open-progress-dialog"); WebDriverUtils.clickLink(driver, by); for (TestObject obj : objs) { ((GoalProgress) obj).create(driver); } by = By.xpath("//span[text()='Save']"); WebDriverUtils.clickButton(driver, by); }
/** * 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); }
/** * 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); } }
public void setGoalTitle_UI(WebDriver driver, String str) { if (!str.equals("")) { By by = By.id("title"); // Navigator.waitForAjaxElementLoad(driver, by); // Navigator.explicitWait(); Navigator.waitForAjax(driver, by); WebDriverUtils.fillin_textbox(driver, by, str); } }
/** * 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()); }
/** * Create goal program * * @param driver */ public void runCreateGoalProgram(WebDriver driver) { // Navigator.navigate(driver, Navigator.URL.GoalManager); Navigator.navigate( driver, Navigator.xmlWebElmtMgr.getNavigationPathList("ManageCenter", "GoalProg"), this); By by = By.id("addButton"); WebDriverUtils.clickButton(driver, by); this.setProgramName_UI(driver, this.getProgramName()); this.setProgramDesc_UI(driver, this.getProgramDesc()); FunctionUI.setDates_UI(driver, this.getStartDate(), "startdatedatebox"); // this.setStartDate_UI(driver, this.getStartDate()); FunctionUI.setDates_UI(driver, this.getTargetDate(), "targetdatedatebox"); // this.setTargetDate_UI(driver, this.getTargetDate()); by = By.id("saveButton"); WebDriverUtils.clickButton(driver, by); }