Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java =================================================================== diff -u -r611e2613de3b4b495727ab1a7bd48ef2a940b349 -r07a21617664f8e2a16319e395b9371433d97e0fc --- lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 611e2613de3b4b495727ab1a7bd48ef2a940b349) +++ lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 07a21617664f8e2a16319e395b9371433d97e0fc) @@ -191,39 +191,45 @@ * Opens LD Dialog to open a design * */ - public void openLdOpenDialog() { + public FLAPage openLdOpenDialog() { openButton.click(); + return PageFactory.initElements(driver, FLAPage.class); } /** * Opens LD Dialog to save a design */ - public void openLdSaveDialog() { + public FLAPage openLdSaveDialog() { saveButton.click(); + + return PageFactory.initElements(driver, FLAPage.class); } /** * Clears canvas to new */ - public void newDesign() { + public FLAPage newDesign() { newButton.click(); checkAlert(); + + return PageFactory.initElements(driver, FLAPage.class); } /** * Drops a group activity into the canvas. * */ - public void dragGroupToCanvas() { + public FLAPage dragGroupToCanvas() { groupButton.click(); canvas.click(); - + + return PageFactory.initElements(driver, FLAPage.class); } @@ -232,7 +238,7 @@ * center of the canvas. * @param name */ - public void dragActivityToCanvas(String name) { + public FLAPage dragActivityToCanvas(String name) { String toolName = "tool" + name; @@ -245,6 +251,7 @@ .build(); // Get the action dragAndDrop.perform(); // Execute the Action + return PageFactory.initElements(driver, FLAPage.class); } /** @@ -255,8 +262,9 @@ * @param name activity name * @param x x offset move * @param y y offset move + * @return */ - public void dragActivityToCanvasPosition(String name, int x, int y) { + public FLAPage dragActivityToCanvasPosition(String name, int x, int y) { // we include the prefix "tool" as that's what we named the ids String toolName = "tool" + name; @@ -275,6 +283,7 @@ // Execute the Action dragAndDrop.perform(); + return PageFactory.initElements(driver, FLAPage.class); } /** @@ -332,9 +341,10 @@ * Rearranges the design on the canvas by pressing * the "Arrange" button. */ - public void arrangeDesign() { + public FLAPage arrangeDesign() { arrangeButton.click(); + return PageFactory.initElements(driver, FLAPage.class); } @@ -345,7 +355,7 @@ * @param seqName * */ - public void openDesign(String seqName) { + public FLAPage openDesign(String seqName) { // opens the dialog openLdOpenDialog(); @@ -367,6 +377,7 @@ // click on open openLdStoreButton.click(); + return PageFactory.initElements(driver, FLAPage.class); } @@ -375,7 +386,12 @@ * It follows the order in which it finds the activities. * */ - public void drawTransitionBtwActivities() { + /** + * Draws transitions in between the activities. + * It follows the order in which it finds the activities. + * @return {@link FLAPage} + */ + public FLAPage drawTransitionBtwActivities() { WebElement svg = driver.findElement(By.tagName("svg")); @@ -395,15 +411,18 @@ //System.out.println("closing"); } + return PageFactory.initElements(driver, FLAPage.class); + } /** * Changes the name in the activity. * * @param activityTitle * @param newActivityTitle + * @return */ - public void changeActivityTitle(String activityTitle, String newActivityTitle) { + public FLAPage changeActivityTitle(String activityTitle, String newActivityTitle) { WebElement svg = driver.findElement(By.tagName("svg")); @@ -424,6 +443,7 @@ // click on canvas so the change takes effect canvas.click(); + return PageFactory.initElements(driver, FLAPage.class); } /** @@ -510,9 +530,10 @@ * Sets a group for an activity * @param groupName the group to set to the activity * @param activityName the activity + * @return * */ - public void setGroupForActivity(String groupName, String activityName) { + public FLAPage setGroupForActivity(String groupName, String activityName) { WebElement svg = driver.findElement(By.tagName("svg")); @@ -527,7 +548,7 @@ canvas.click(); - + return PageFactory.initElements(driver, FLAPage.class); } @@ -537,7 +558,7 @@ * @param fromActivity from activity name * @param toActivity to activity name */ - public void drawTransitionFromTo(String fromActivity, String toActivity) { + public FLAPage drawTransitionFromTo(String fromActivity, String toActivity) { WebElement svg = driver.findElement(By.tagName("svg")); @@ -547,18 +568,48 @@ transitionButton.click(); fromActivityElement.click(); toActivityElement.click(); - + canvas.click(); + return PageFactory.initElements(driver, FLAPage.class); } + /** + * Draws a branching by drawing more than 1 transition from the same activity + * + * This test the feature when drawing two transitions from the same activity, it will prompt + * the user to create a branching activity. + * + * @param fromActivity from activity name + * @param toActivities to activities name + */ + public FLAPage drawBranchingFromActivity(String fromActivity, List toActivities) { + WebElement svg = driver.findElement(By.tagName("svg")); + WebElement fromActivityElement = getActivityElement(svg, fromActivity); + + + for (String toActivity : toActivities) { + + WebElement toActivityElement = getActivityElement(svg, toActivity); + + transitionButton.click(); + fromActivityElement.click(); + toActivityElement.click(); + checkAlert(); + canvas.click(); + + } + + return PageFactory.initElements(driver, FLAPage.class); + } + /** * Copy/pastes a given activity * @param activity activity to copy/paste */ - public void copyPasteActivity(String activity) { + public FLAPage copyPasteActivity(String activity) { WebElement svg = driver.findElement(By.tagName("svg")); // Select activity @@ -568,8 +619,8 @@ pasteButton.click(); + return PageFactory.initElements(driver, FLAPage.class); - } @@ -592,7 +643,7 @@ * * @param activity */ - public void deleteActivity(String activity) { + public FLAPage deleteActivity(String activity) { WebElement svg = driver.findElement(By.tagName("svg")); @@ -615,6 +666,7 @@ binActivityAction.perform(); // Execute the Action + return PageFactory.initElements(driver, FLAPage.class); } @@ -795,7 +847,7 @@ return activity.getLocation(); } - public void dragGateToCanvas() { + public FLAPage dragGateToCanvas() { flowDropButton.click(); gateButton.click(); @@ -810,13 +862,14 @@ // Execute the Action dropGate.perform(); + return PageFactory.initElements(driver, FLAPage.class); } /** * Drags a branching activity into the canvas and sets up both start * and ending points. */ - public void dragBranchToCanvas() { + public FLAPage dragBranchToCanvas() { flowDropButton.click(); branchingButton.click(); @@ -832,6 +885,8 @@ // Execute the Action dropBranch.perform(); + + return PageFactory.initElements(driver, FLAPage.class); }