Index: lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java =================================================================== diff -u -r54e27d396f92c7977bae72fc2e62598a6a8a1150 -r3efe43338b4e0ca5b68f60752f95a90c919121fb --- lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java (.../AuthorTests.java) (revision 54e27d396f92c7977bae72fc2e62598a6a8a1150) +++ lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java (.../AuthorTests.java) (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) @@ -25,18 +25,19 @@ import java.util.List; import java.util.concurrent.TimeUnit; -import org.lamsfoundation.lams.pages.author.FLAPage; +import org.lamsfoundation.lams.author.util.AuthorConstants; import org.lamsfoundation.lams.pages.IndexPage; import org.lamsfoundation.lams.pages.LoginPage; +import org.lamsfoundation.lams.pages.author.FLAPage; import org.lamsfoundation.lams.util.LamsUtil; import org.openqa.selenium.Point; import org.openqa.selenium.WebDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.support.PageFactory; import org.testng.Assert; -import org.testng.annotations.Test; -import org.testng.annotations.BeforeClass; import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; /** * Authoring tests for: @@ -68,18 +69,6 @@ public class AuthorTests { - // Constants - - private static final String FLA_TITLE = "Flashless Authoring"; - private static final String SAVE_SEQUENCE_SUCCESS_MSG = "Congratulations"; - private static final String SAVE_SEQUENCE_INVALID_MSG = "validation issues"; - - private static final String FORUM_TITLE = "Forum"; - private static final String KALTURA_TITLE = "Kaltura"; - private static final String SHARE_RESOURCES_TITLE = "Share Resources"; - private static final String Q_AND_A_TITLE = "Q & A"; - private static final String GROUP_TITLE = "Grouping"; - private static final String randomInt = LamsUtil.randInt(0, 9999); private String randomDesignName = "Design-" + randomInt; @@ -117,7 +106,7 @@ FLAPage fla = new FLAPage(driver); fla = index.openFla(); fla.maximizeWindows(); - Assert.assertEquals(FLA_TITLE, fla.getTitle(), "The expected title is not present"); + Assert.assertEquals(AuthorConstants.FLA_TITLE, fla.getTitle(), "The expected title is not present"); @@ -130,25 +119,25 @@ public void createDesign() { // Drop activities in canvas - fla.dragActivityToCanvasPosition(FORUM_TITLE, 200, 250); - fla.dragActivityToCanvasPosition(SHARE_RESOURCES_TITLE, 350, (10 * randomInteger)); - fla.dragActivityToCanvasPosition(KALTURA_TITLE, 550, (80 * randomInteger)); - fla.dragActivityToCanvas(Q_AND_A_TITLE); + fla.dragActivityToCanvasPosition(AuthorConstants.FORUM_TITLE, 200, 250); + fla.dragActivityToCanvasPosition(AuthorConstants.SHARE_RESOURCES_TITLE, 350, (10 * randomInteger)); + fla.dragActivityToCanvasPosition(AuthorConstants.KALTURA_TITLE, 550, (80 * randomInteger)); + fla.dragActivityToCanvas(AuthorConstants.Q_AND_A_TITLE); fla.drawTransitionBtwActivities(); // Now get all the activity titles List allActivityTitles = fla.getAllActivityNames(); // Assert that all of them are in the design - Assert.assertTrue(allActivityTitles.contains(FORUM_TITLE), - "The title " + FORUM_TITLE + " was not found as an activity in the design"); - Assert.assertTrue(allActivityTitles.contains(SHARE_RESOURCES_TITLE), - "The title " + SHARE_RESOURCES_TITLE + " was not found as an activity in the design"); - Assert.assertTrue(allActivityTitles.contains(KALTURA_TITLE), - "The title " + KALTURA_TITLE + " was not found as an activity in the design"); - Assert.assertTrue(allActivityTitles.contains(Q_AND_A_TITLE), - "The title " + Q_AND_A_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.FORUM_TITLE), + "The title " + AuthorConstants.FORUM_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.SHARE_RESOURCES_TITLE), + "The title " + AuthorConstants.SHARE_RESOURCES_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.KALTURA_TITLE), + "The title " + AuthorConstants.KALTURA_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.Q_AND_A_TITLE), + "The title " + AuthorConstants.Q_AND_A_TITLE + " was not found as an activity in the design"); } /** @@ -159,7 +148,7 @@ System.out.println("design name: " + randomDesignName); String saveResult = fla.saveDesign(randomDesignName); // System.out.println(saveResult); - Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_SUCCESS_MSG), + Assert.assertTrue(saveResult.contains(AuthorConstants.SAVE_SEQUENCE_SUCCESS_MSG), "Saving a design returned an unexpected message: "+ saveResult); } @@ -218,11 +207,11 @@ @Test(dependsOnMethods={"saveAsDesign"}) public void changeActivityTitle() { - String forumNewTitle = "New " + FORUM_TITLE; - String kalturaNewTitle = "New " + KALTURA_TITLE; + String forumNewTitle = "New " + AuthorConstants.FORUM_TITLE; + String kalturaNewTitle = "New " + AuthorConstants.KALTURA_TITLE; - fla.changeActivityTitle(FORUM_TITLE, forumNewTitle); - fla.changeActivityTitle(KALTURA_TITLE, kalturaNewTitle); + fla.changeActivityTitle(AuthorConstants.FORUM_TITLE, forumNewTitle); + fla.changeActivityTitle(AuthorConstants.KALTURA_TITLE, kalturaNewTitle); List allActivityTitles = fla.getAllActivityNames(); System.out.println("All Activites: "+ allActivityTitles); @@ -245,17 +234,17 @@ cleanCanvas(); fla.dragGroupToCanvas(); fla.arrangeDesign(); - fla.dragActivityToCanvasPosition(FORUM_TITLE, 150, 100); + fla.dragActivityToCanvasPosition(AuthorConstants.FORUM_TITLE, 150, 100); fla.arrangeDesign(); fla.drawTransitionBtwActivities(); String newGroupTitle = "New Group"; // + GROUP_TITLE; - fla.changeActivityTitle(GROUP_TITLE, newGroupTitle); + fla.changeActivityTitle(AuthorConstants.GROUP_TITLE, newGroupTitle); - fla.setGroupForActivity("New Group", FORUM_TITLE); + fla.setGroupForActivity("New Group", AuthorConstants.FORUM_TITLE); - String designName = randomDesignName + "-" + GROUP_TITLE; + String designName = randomDesignName + "-" + AuthorConstants.GROUP_TITLE; fla.saveAsDesign(designName); @@ -272,12 +261,12 @@ @Test(dependsOnMethods={"createGroupDesign"}) public void drawQaActivity() { - fla.dragActivityToCanvas(Q_AND_A_TITLE); + fla.dragActivityToCanvas(AuthorConstants.Q_AND_A_TITLE); - boolean activityExists = fla.activityExists(Q_AND_A_TITLE); + boolean activityExists = fla.activityExists(AuthorConstants.Q_AND_A_TITLE); Assert.assertTrue(activityExists, - "The activity " + Q_AND_A_TITLE + " is not present in design"); + "The activity " + AuthorConstants.Q_AND_A_TITLE + " is not present in design"); } @@ -290,7 +279,7 @@ String saveResult = fla.saveDesign(); - Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_INVALID_MSG), + Assert.assertTrue(saveResult.contains(AuthorConstants.SAVE_SEQUENCE_INVALID_MSG), "The save design returns an unexpected message: " + saveResult ); } @@ -302,7 +291,7 @@ @Test(dependsOnMethods={"saveInvalidDesign"}) public void fixValidation() { - fla.drawTransitionFromTo(FORUM_TITLE, Q_AND_A_TITLE); + fla.drawTransitionFromTo(AuthorConstants.FORUM_TITLE, AuthorConstants.Q_AND_A_TITLE); } @@ -315,7 +304,7 @@ String saveResult = fla.saveDesign(); - Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_SUCCESS_MSG), + Assert.assertTrue(saveResult.contains(AuthorConstants.SAVE_SEQUENCE_SUCCESS_MSG), "The save design returns an invalid message: " + saveResult ); } @@ -441,8 +430,8 @@ @Test(dependsOnMethods={"addDesignLicense"}) public void copyPasteActivity() { - String copyOfActivity = "Copy of " + Q_AND_A_TITLE; - fla.copyPasteActivity(Q_AND_A_TITLE); + String copyOfActivity = "Copy of " + AuthorConstants.Q_AND_A_TITLE; + fla.copyPasteActivity(AuthorConstants.Q_AND_A_TITLE); Boolean activityExists = fla.activityExists(copyOfActivity); @@ -460,14 +449,14 @@ @Test(dependsOnMethods={"copyPasteActivity"}) public void arrangeDesign() { - Point initialActivityLocation = fla.getActivityLocation(Q_AND_A_TITLE); + Point initialActivityLocation = fla.getActivityLocation(AuthorConstants.Q_AND_A_TITLE); reArrangeDesign(); - Point newActivityLocation = fla.getActivityLocation(Q_AND_A_TITLE); + Point newActivityLocation = fla.getActivityLocation(AuthorConstants.Q_AND_A_TITLE); Assert.assertFalse(initialActivityLocation.equals(newActivityLocation), - "The activity " + Q_AND_A_TITLE + " is still in the same location!" ); + "The activity " + AuthorConstants.Q_AND_A_TITLE + " is still in the same location!" ); saveInvalidDesign(); @@ -484,7 +473,7 @@ @Test(enabled = false, dependsOnMethods={"fixValidationAndSave"}) public void deleteActivity() { - String copyOfActivity = "Copy of " + Q_AND_A_TITLE; + String copyOfActivity = "Copy of " + AuthorConstants.Q_AND_A_TITLE; fla.deleteActivity(copyOfActivity); Boolean activityExists = fla.activityExists(copyOfActivity); Index: lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java =================================================================== diff -u --- lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java (revision 0) +++ lams_tests/tests/org/lamsfoundation/lams/author/GatesTests.java (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) @@ -0,0 +1,342 @@ +/**************************************************************** + * Copyright (C) 2014 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ +package org.lamsfoundation.lams.author; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import org.lamsfoundation.lams.author.util.AuthorConstants; +import org.lamsfoundation.lams.pages.IndexPage; +import org.lamsfoundation.lams.pages.LoginPage; +import org.lamsfoundation.lams.pages.author.FLAPage; +import org.lamsfoundation.lams.util.LamsUtil; +import org.openqa.selenium.Point; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.firefox.FirefoxDriver; +import org.openqa.selenium.support.PageFactory; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.AfterClass; + +/** + * Authoring Gate tests: + * + * - Creates a design with a gate + * - Adds title to gate + * - Adds description to gate + * - Sets gate type: + * - permission + * - synchronization + * - condition + * - schedule + * + * + * @author Ernie Ghiglione (ernieg@lamsfoundation.org) + * + */ +public class GatesTests { + + // Gates constants + + private static final String GATE_TYPE_CONDITION = "condition"; + private static final String GATE_TYPE_SYNC = "sync"; + private static final String GATE_TYPE_SCHEDULE = "schedule"; + private static final String GATE_TYPE_PERMISSION = "permission"; + + + private static final String randomInt = LamsUtil.randInt(0, 9999); + + private String randomDesignName = "Design-" + randomInt; + private int randomInteger = Integer.parseInt(LamsUtil.randInt(0, 5)); + + private LoginPage onLogin; + private IndexPage index; + private FLAPage fla; + + WebDriver driver; + + @BeforeClass + public void beforeClass() { + driver = new FirefoxDriver(); + driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); + + onLogin = PageFactory.initElements(driver, LoginPage.class); + index = PageFactory.initElements(driver, IndexPage.class); + fla = PageFactory.initElements(driver, FLAPage.class); + onLogin.navigateToLamsLogin().loginAs("test3", "test3"); + + } + + @AfterClass + public void afterClass() { + // driver.quit(); + } + + + + /** + * Opens FLA interface + */ + @Test + public void openFLA() { + + FLAPage fla = new FLAPage(driver); + fla = index.openFla(); + fla.maximizeWindows(); + Assert.assertEquals(AuthorConstants.FLA_TITLE, fla.getTitle(), "The expected title is not present"); + + + + } + + + /** + * Creates a design with a gate + */ + @Test(dependsOnMethods={"openFLA"}) + public void createDesign() { + + // Drop activities in canvas + fla.dragActivityToCanvasPosition(AuthorConstants.FORUM_TITLE, 200, 50); + fla.dragGateToCanvas(); + fla.dragActivityToCanvasPosition(AuthorConstants.SHARE_RESOURCES_TITLE, 350, (10 * randomInteger)); + + // Draw transitions in between the activities + fla.drawTransitionFromTo(AuthorConstants.FORUM_TITLE, AuthorConstants.GATE_TITLE); + fla.drawTransitionFromTo(AuthorConstants.GATE_TITLE, AuthorConstants.SHARE_RESOURCES_TITLE); + + // Now get all the activity titles + List allActivityTitles = fla.getAllActivityNames(); + + // Assert that all of them are in the design + + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.FORUM_TITLE), + "The title " + AuthorConstants.FORUM_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.GATE_TITLE), + "The title " + AuthorConstants.GATE_TITLE + " was not found as an activity in the design"); + Assert.assertTrue(allActivityTitles.contains(AuthorConstants.SHARE_RESOURCES_TITLE), + "The title " + AuthorConstants.SHARE_RESOURCES_TITLE + " was not found as an activity in the design"); + + + } + /** + * Saves design + */ + @Test(dependsOnMethods={"createDesign"}) + public void namesAndSavesDesign() { + + String saveResult = fla.saveDesign(randomDesignName); + + Assert.assertTrue(saveResult.contains(AuthorConstants.SAVE_SEQUENCE_SUCCESS_MSG), "Error while saving design"); + + } + + + /** + * Arranges the design + */ + @Test(dependsOnMethods={"namesAndSavesDesign"}) + public void arrangeDesign() { + + Point initialActivityLocation = fla.getActivityLocation(AuthorConstants.GATE_TITLE); + + fla.arrangeDesign(); + + Point newActivityLocation = fla.getActivityLocation(AuthorConstants.GATE_TITLE); + + Assert.assertFalse(initialActivityLocation.equals(newActivityLocation), + "The activity " + AuthorConstants.GATE_TITLE + " is still in the same location!" ); + + } + + /** + * Saves new re-arranged design + */ + @Test(dependsOnMethods={"arrangeDesign"}) + public void savesDesign() { + + String saveResult = fla.saveDesign(); + + Assert.assertTrue(saveResult.contains(AuthorConstants.SAVE_SEQUENCE_SUCCESS_MSG), "Error while saving design: " + saveResult); + } + + + /** + * Set Gate title + */ + @Test(dependsOnMethods={"savesDesign"}) + public void setGateTitle() { + + String gateTitleText = "Gate 01"; + + fla.gateProperties().setGateTitle(gateTitleText); + + String assertGateTitle = fla.gateProperties().getGateTitle(); + + Assert.assertEquals(assertGateTitle, gateTitleText, "Gate title is not the same"); + + + } + + /** + * Set Gate description + */ + @Test(dependsOnMethods={"setGateTitle"}) + public void setGateDescription() { + + String gateDescriptionText = "This is a gate"; + + fla.gateProperties().setGateDescription(gateDescriptionText); + + String assertGateDescription = fla.gateProperties().getGateDescription(); + + Assert.assertEquals(assertGateDescription, gateDescriptionText, "Gate description is not the same"); + + + } + + /** + * We implement a data provider so iterate thru the gate types + * + */ + @DataProvider(name = "gateTypes") + public static Object[][] gateTyoes() { + return new Object[][] { + new Object[] { GATE_TYPE_CONDITION } , { GATE_TYPE_PERMISSION} , + { GATE_TYPE_SCHEDULE }, { GATE_TYPE_SYNC } + }; + } + + + /** + * Checks that all Gate types are available and can be set + */ + @Test(dataProvider = "gateTypes", dependsOnMethods={"setGateDescription"}) + public void setGateType(String gateType) { + + + fla.gateProperties().setGateType(gateType); + + String assertGateType = fla.gateProperties().getGateType(); + + Assert.assertEquals(assertGateType, gateType, "Gate type is not the same"); + + + } + + /** + * Set a Permission gate and save + */ + @Test(dependsOnMethods="setGateType") + public void setGateTypeToPermission() { + setGateType(GATE_TYPE_PERMISSION); + savesDesign(); + } + + /** + * Set a Sync gate and save + */ + @Test(dependsOnMethods="setGateTypeToPermission") + public void setGateTypeToSync() { + setGateType(GATE_TYPE_SYNC); + savesDesign(); + } + + /** + * Set a Schedule gate, its properties and save + */ + @Test(dependsOnMethods="setGateTypeToSync") + public void setGateTypeToSchedule() { + final String scheduleDays = "2"; + final String scheduleHours = "10"; + final String scheduleMinutes = "45"; + + setGateType(GATE_TYPE_SCHEDULE); + + // Set days property + fla.gateProperties().setScheduleDays(scheduleDays); + + // Set hours property + fla.gateProperties().setScheduleHours(scheduleHours); + + // Set hours property + fla.gateProperties().setScheduleMinutes(scheduleMinutes); + + // Set since finished previews activity option + fla.gateProperties().setSincePreviewActivity(); + + // Save + savesDesign(); + + // Now run assertions + + + // Days + String assertScheduleDays = fla.gateProperties() + .getScheduleDays(); + Assert.assertEquals(scheduleDays, assertScheduleDays, + "The days in the schedule gate don't match"); + + // Hours + String assertScheduleHours = fla.gateProperties() + .getScheduleHours(); + Assert.assertEquals(scheduleHours, assertScheduleHours, + "The days in the schedule gate don't match"); + + // Minutes + String assertScheduleMinutes = fla.gateProperties() + .getScheduleMinutes(); + Assert.assertEquals(scheduleMinutes, assertScheduleMinutes, + "The days in the schedule gate don't match"); + + // Since previews activity + Boolean assertIsSincePreviews = fla.gateProperties() + .isSincePreviewActivity(); + Assert.assertTrue(assertIsSincePreviews, + "Option Since finish previews activity is not on"); + + } + + /** + * Set a Schedule gate, its properties and save + */ + @Test(dependsOnMethods="setGateTypeToSchedule") + public void setGateTypeToCondition() { + + fla.gateProperties() + .setGateType(GATE_TYPE_CONDITION) + .setGateTitle("Condition Gate") + .setGateDescription("Testing condition gate") + .setConditionInput(AuthorConstants.FORUM_TITLE); + + savesDesign(); + + // Now assertions + + String assertConditionInput = fla.gateProperties().getConditionInput(); + Assert.assertEquals(assertConditionInput, AuthorConstants.FORUM_TITLE, + "Condition input activity is not the same!"); + + } +} Index: lams_tests/tests/org/lamsfoundation/lams/author/util/AuthorConstants.java =================================================================== diff -u --- lams_tests/tests/org/lamsfoundation/lams/author/util/AuthorConstants.java (revision 0) +++ lams_tests/tests/org/lamsfoundation/lams/author/util/AuthorConstants.java (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) @@ -0,0 +1,41 @@ +/**************************************************************** + * Copyright (C) 2014 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.author.util; + +public class AuthorConstants { + + // Constants + + public static final String FLA_TITLE = "Flashless Authoring"; + public static final String SAVE_SEQUENCE_SUCCESS_MSG = "Congratulations"; + public static final String SAVE_SEQUENCE_INVALID_MSG = "validation issues"; + + public static final String FORUM_TITLE = "Forum"; + public static final String KALTURA_TITLE = "Kaltura"; + public static final String SHARE_RESOURCES_TITLE = "Share Resources"; + public static final String Q_AND_A_TITLE = "Q & A"; + + public static final String GATE_TITLE = "STOP"; + public static final String GROUP_TITLE = "Grouping"; + +} Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java =================================================================== diff -u -r54e27d396f92c7977bae72fc2e62598a6a8a1150 -r3efe43338b4e0ca5b68f60752f95a90c919121fb --- lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 54e27d396f92c7977bae72fc2e62598a6a8a1150) +++ lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) @@ -28,6 +28,7 @@ import java.util.List; import java.util.Set; +import org.lamsfoundation.lams.author.util.AuthorConstants; import org.lamsfoundation.lams.pages.AbstractPage; import org.openqa.selenium.Alert; import org.openqa.selenium.By; @@ -61,7 +62,10 @@ @FindBy(id = "openButton") private WebElement openButton; - + + @FindBy(id = "openDropButton") + private WebElement openDropButton; + @FindBy(id = "importDesignButton") private WebElement importDesignButton; @@ -92,6 +96,9 @@ @FindBy(id = "flowButton") private WebElement flowButton; + + @FindBy(id = "flowDropButton") + private WebElement flowDropButton; @FindBy(id = "gateButton") private WebElement gateButton; @@ -104,6 +111,9 @@ @FindBy(id = "annotateButton") private WebElement annotateButton; + + @FindBy(id = "annotateDropButton") + private WebElement annotateDropButton; @FindBy(id = "annotateLabelButton") private WebElement annotateLabelButton; @@ -712,6 +722,22 @@ } + /** + * Gate properties UI component + * + * @return DescriptionPage object + */ + public GatePropertyPage gateProperties() { + + + WebElement svg = driver.findElement(By.tagName("svg")); + WebElement gateActivity = getActivityElement(svg, AuthorConstants.GATE_TITLE); + + gateActivity.click(); + return PageFactory.initElements(driver, GatePropertyPage.class); + + } + public String getGroupType(String groupActivityName) { final String selectGroupDropDownXpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[2]/td[2]/select"; @@ -747,7 +773,24 @@ return activity.getLocation(); } + public void dragGateToCanvas() { + flowDropButton.click(); + gateButton.click(); + + // Prepare the dragAndDrop action + Actions builder = new Actions(driver); // Configure the Action + Action dropGate = builder + .moveToElement(canvas) + .click() + .build(); + + // Execute the Action + dropGate.perform(); + + } + + /** * Returns the correct popup id @@ -952,7 +995,5 @@ inputNumGroups.sendKeys(Integer.toString(numberOfGroups)); } - - } Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java =================================================================== diff -u --- lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java (revision 0) +++ lams_tests/tests/org/lamsfoundation/lams/pages/author/GatePropertyPage.java (revision 3efe43338b4e0ca5b68f60752f95a90c919121fb) @@ -0,0 +1,243 @@ +/**************************************************************** + * Copyright (C) 2014 LAMS Foundation (http://lamsfoundation.org) + * ============================================================= + * License Information: http://lamsfoundation.org/licensing/lams/2.0/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2.0 + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 * USA + * + * http://www.gnu.org/licenses/gpl.txt + * **************************************************************** + */ + +package org.lamsfoundation.lams.pages.author; + +import org.lamsfoundation.lams.pages.AbstractPage; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.FindBy; +import org.openqa.selenium.support.PageFactory; +import org.openqa.selenium.support.ui.Select; + +public class GatePropertyPage extends AbstractPage { + + /** + * Gate properties + * + */ + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[1]/td[2]/input") + private WebElement gateTitle; + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[2]/td[2]/textarea") + private WebElement gateDescription; + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[3]/td[2]/select") + private WebElement gateTypeSelect; + + + /** + * Schedule gate properties + * + */ + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[5]/td[2]/span/input") + private WebElement scheduleDays; + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[5]/td[3]/span/input") + private WebElement scheduleHours; + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[5]/td[4]/span/input") + private WebElement scheduleMinutes; + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[6]/td[2]/input") + private WebElement sincePreviewActivity; + + + /** + * Schedule gate properties + * + */ + + @FindBy(xpath = "/html/body/div[14]/div[2]/div/table/tbody/tr[4]/td[2]/select") + private WebElement conditionInputSelect; + + @FindBy (xpath ="/html/body/div[14]/div[2]/div/table/tbody/tr[7]/td/div/span") + private WebElement createConditionsButton; + + + public GatePropertyPage(WebDriver driver) { + super(driver); + + } + + + /** + * Set gate title + * + * @param designDescription + * @return + */ + public GatePropertyPage setGateTitle(String gateTitleText) { + + gateTitle.click(); + gateTitle.clear(); + gateTitle.sendKeys(gateTitleText); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + + /** + * Returns gate title + * @return gate title + */ + public String getGateTitle() { + + return gateTitle.getAttribute("value"); + + } + + + /** + * Sets gate description + * @param gateDescriptionText + * @return + */ + public GatePropertyPage setGateDescription(String gateDescriptionText) { + + + gateDescription.click(); + gateDescription.clear(); + gateDescription.sendKeys(gateDescriptionText); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + /** + * Returns gate description + * @return gate description + */ + public String getGateDescription() { + + return gateDescription.getAttribute("value"); + + } + + + /** + * Set gate type in select + * @param gateType + * @return + */ + public GatePropertyPage setGateType(String gateType) { + + Select gateSelect = new Select(gateTypeSelect); + + gateSelect.selectByValue(gateType); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + + /** + * Returns gate type value + * @return gate type value + */ + public String getGateType() { + + Select gateSelect = new Select(gateTypeSelect); + + return gateSelect.getFirstSelectedOption().getAttribute("value"); + + } + + public GatePropertyPage setScheduleDays(String days) { + + scheduleDays.click(); + scheduleDays.clear(); + scheduleDays.sendKeys(days); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + public String getScheduleDays() { + + return scheduleDays.getAttribute("value"); + + } + + + public GatePropertyPage setScheduleHours(String hours) { + + scheduleHours.click(); + scheduleHours.clear(); + scheduleHours.sendKeys(hours); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + public String getScheduleHours() { + + return scheduleHours.getAttribute("value"); + + } + + public GatePropertyPage setScheduleMinutes(String minutes) { + + scheduleMinutes.click(); + scheduleMinutes.clear(); + scheduleMinutes.sendKeys(minutes); + + return PageFactory.initElements(driver, GatePropertyPage.class); + + } + + public String getScheduleMinutes() { + + return scheduleMinutes.getAttribute("value"); + + } + + public GatePropertyPage setSincePreviewActivity() { + + sincePreviewActivity.click(); + + return PageFactory.initElements(driver, GatePropertyPage.class); + + } + + public Boolean isSincePreviewActivity() { + + return sincePreviewActivity.isSelected(); + + } + + + public GatePropertyPage setConditionInput(String activity) { + + Select inputDropDown = new Select(conditionInputSelect); + + inputDropDown.selectByVisibleText(activity.trim()); + + return PageFactory.initElements(driver, GatePropertyPage.class); + } + + public String getConditionInput() { + + Select inputDropDown = new Select(conditionInputSelect); + + return inputDropDown.getFirstSelectedOption().getText(); + + } +}