Index: lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java
===================================================================
diff -u -r077b9d360fde841db54cae0b4df5db8ed3f4049e -r54e27d396f92c7977bae72fc2e62598a6a8a1150
--- lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java (.../AuthorTests.java) (revision 077b9d360fde841db54cae0b4df5db8ed3f4049e)
+++ lams_tests/tests/org/lamsfoundation/lams/author/AuthorTests.java (.../AuthorTests.java) (revision 54e27d396f92c7977bae72fc2e62598a6a8a1150)
@@ -23,12 +23,13 @@
package org.lamsfoundation.lams.author;
import java.util.List;
+import java.util.concurrent.TimeUnit;
import org.lamsfoundation.lams.pages.author.FLAPage;
-import org.lamsfoundation.lams.pages.AbstractPage;
import org.lamsfoundation.lams.pages.IndexPage;
import org.lamsfoundation.lams.pages.LoginPage;
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;
@@ -50,7 +51,16 @@
* - saveAs design
* - change activity titles
* - save (one click)
- * - open activity authoring
+ * - Create group
+ * - Assign group to activity
+ * - Modify group settings
+ * - Add design description
+ * - Add design license
+ * - Copy/paste activities
+ * - Arrange design
+ * - Save invalid design
+ *
+ *
*
* @author Ernie Ghiglione (ernieg@lamsfoundation.org)
*
@@ -62,11 +72,13 @@
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);
@@ -76,24 +88,24 @@
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("test2", "test2");
+ onLogin.navigateToLamsLogin().loginAs("test3", "test3");
}
@AfterClass
public void afterClass() {
- //driver.quit();
+ driver.quit();
}
/**
@@ -112,16 +124,16 @@
}
/**
- * Creates a 4 activity sequence
+ * Creates a 4 activity design
*/
@Test(dependsOnMethods={"openFLA"})
public void createDesign() {
- // Drop activites in canvas
- fla.dragActivityToCanvas(FORUM_TITLE);
- fla.dragActivityToCanvasPosition(SHARE_RESOURCES_TITLE, 250, (20 * randomInteger));
- fla.dragActivityToCanvasPosition(KALTURA_TITLE, (350 * randomInteger), 120);
- fla.dragActivityToCanvasPosition(Q_AND_A_TITLE, 600, (14 * randomInteger));
+ // 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.drawTransitionBtwActivities();
// Now get all the activity titles
@@ -139,54 +151,69 @@
"The title " + Q_AND_A_TITLE + " was not found as an activity in the design");
}
+ /**
+ * Gives the design a new name and saves it
+ */
@Test(dependsOnMethods={"createDesign"})
public void nameAndSaveDesign() {
-
+ System.out.println("design name: " + randomDesignName);
String saveResult = fla.saveDesign(randomDesignName);
// System.out.println(saveResult);
Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_SUCCESS_MSG),
- "Saving a sequence returned an unexpected message: "+ saveResult);
+ "Saving a design returned an unexpected message: "+ saveResult);
}
+ /**
+ * Clears the canvas
+ */
@Test(dependsOnMethods={"nameAndSaveDesign"})
public void cleanCanvas() {
fla.newDesign();
// Check that the design titled is back to untitled
- String newTitle = fla.getSequenceName();
+ String newTitle = fla.getDesignName();
Assert.assertTrue(newTitle.equals("Untitled"), "The canvas wasn't clean. Still shows: " + newTitle);
}
+ /**
+ * Opens a design
+ */
@Test(dependsOnMethods={"cleanCanvas"})
public void reOpenDesign() {
fla.openDesign(randomDesignName);
- Assert.assertEquals(fla.getSequenceName(), randomDesignName);
+ Assert.assertEquals(fla.getDesignName(), randomDesignName);
}
+ /**
+ * Arranges design activities using "Arrange" menu button
+ */
@Test(dependsOnMethods={"reOpenDesign"})
public void reArrangeDesign() {
fla.arrangeDesign();
}
+ /**
+ * SaveAs a design
+ */
@Test(dependsOnMethods={"reOpenDesign"})
public void saveAsDesign() {
- String newSequenceName = "Re" + randomDesignName;
- fla.saveAsDesign(newSequenceName);
- Assert.assertEquals(fla.getSequenceName(), newSequenceName);
+ String newDesignName = "Re" + randomDesignName;
+ fla.saveAsDesign(newDesignName);
+ Assert.assertEquals(fla.getDesignName(), newDesignName);
}
/**
- *
+ * Change activity title
*/
@Test(dependsOnMethods={"saveAsDesign"})
public void changeActivityTitle() {
@@ -208,20 +235,267 @@
}
-
+
+ /**
+ * Creates a design using a grouping activity
+ */
@Test(dependsOnMethods={"changeActivityTitle"})
- public void openActivity() {
+ public void createGroupDesign () {
- AbstractPage forumPage = fla.openSpecificActivity("New " + FORUM_TITLE);
+ cleanCanvas();
+ fla.dragGroupToCanvas();
+ fla.arrangeDesign();
+ fla.dragActivityToCanvasPosition(FORUM_TITLE, 150, 100);
+ fla.arrangeDesign();
+
+ fla.drawTransitionBtwActivities();
+
+ String newGroupTitle = "New Group"; // + GROUP_TITLE;
+ fla.changeActivityTitle(GROUP_TITLE, newGroupTitle);
+
+ fla.setGroupForActivity("New Group", FORUM_TITLE);
+
+ String designName = randomDesignName + "-" + GROUP_TITLE;
+
+ fla.saveAsDesign(designName);
+
+ Assert.assertEquals(fla.getDesignName(), designName,
+ "Design name is wrong. It should be: " + designName);
+
+ }
- String forumPageTitle = forumPage.getTitle();
- forumPage.closeWindow();
+
+ /**
+ * Draws a new Q&A Activity
+ *
+ */
+ @Test(dependsOnMethods={"createGroupDesign"})
+ public void drawQaActivity() {
- Assert.assertEquals(forumPageTitle, FORUM_TITLE,
- "The title seems to be different from what we expected.");
+ fla.dragActivityToCanvas(Q_AND_A_TITLE);
+
+ boolean activityExists = fla.activityExists(Q_AND_A_TITLE);
+
+ Assert.assertTrue(activityExists,
+ "The activity " + Q_AND_A_TITLE + " is not present in design");
+
+ }
+
+ /**
+ * Saves an invalid design
+ *
+ */
+ @Test(dependsOnMethods={"drawQaActivity"})
+ public void saveInvalidDesign() {
+
+ String saveResult = fla.saveDesign();
+
+ Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_INVALID_MSG),
+ "The save design returns an unexpected message: " + saveResult );
+
+ }
+
+ /**
+ * Fix validation and saves a valid design
+ *
+ */
+ @Test(dependsOnMethods={"saveInvalidDesign"})
+ public void fixValidation() {
+
+ fla.drawTransitionFromTo(FORUM_TITLE, Q_AND_A_TITLE);
+
+ }
+
+ /**
+ * Saves design
+ *
+ */
+ @Test(dependsOnMethods={"fixValidation"})
+ public void saveDesign() {
+
+ String saveResult = fla.saveDesign();
+
+ Assert.assertTrue(saveResult.contains(SAVE_SEQUENCE_SUCCESS_MSG),
+ "The save design returns an invalid message: " + saveResult );
+
+ }
+
+ /**
+ * Set group settings to random groups
+ *
+ * Sets up some groups and modifications
+ *
+ */
+ @Test(dependsOnMethods={"saveDesign"})
+ public void changeGroupSettingsToRandom() {
+
+ final String groupActivityName = "New Group";
+ final String groupTypeRandom = "random";
+
+ // set random grouping and number of learners to 3
+ fla.setGroups(groupActivityName, groupTypeRandom, true, 3, "", "");
+
+ /// Get assertions
+ String testGroupType = fla.getGroupType(groupActivityName);
+ Assert.assertEquals(testGroupType, groupTypeRandom, "The group type returned is incorrect");
+
+ }
+
+ /**
+ * Change Group settings to select in monitor
+ *
+ * Sets up some groups and modifications
+ *
+ */
+ @Test(dependsOnMethods={"changeGroupSettingsToRandom"})
+ public void changeGroupSettingsToMonitor() {
+ final String groupActivityName = "New Group";
+ final String groupTypeMonitor = "monitor";
+
+ // set teacher selection (monitor) 4 groups and pass names
+ fla.setGroups(groupActivityName, groupTypeMonitor, true, 4, "Group Blue, Group Yellow, Group Red, Group Orange", "");
+ /// Get assertions
+ String testGroupType = fla.getGroupType(groupActivityName);
+ Assert.assertEquals(testGroupType, groupTypeMonitor, "The group type returned is incorrect");
+
}
+ /**
+ * Change Group settings to learner selection
+ *
+ * Sets up some groups and modifications
+ *
+ */
+ @Test(dependsOnMethods={"changeGroupSettingsToMonitor"})
+ public void changeGroupSettingsToLearner() {
+
+ final String groupActivityName = "New Group";
+ final String groupTypeLearner = "learner";
+
+ // set learner choice, 5 groups, equal group sizes, view learners before select
+ fla.setGroups(groupActivityName, groupTypeLearner, false, 5, "", "true,true");
+
+ /// Get assertions
+ String testGroupType = fla.getGroupType(groupActivityName);
+ Assert.assertEquals(testGroupType, groupTypeLearner, "The group type returned is incorrect");
+
+ }
+
+ /**
+ * Adds description to design
+ *
+ */
+ @Test(dependsOnMethods={"changeGroupSettingsToLearner"})
+ public void addDesignDescription() {
+
+
+ String designDescription = "This is the description for this design";
+
+ // opens dialog
+ fla.designDescription()
+ .openDesignDescriptionDialog();
+
+ // Adds description
+ fla.designDescription()
+ .addDesignDescription(designDescription);
+
+ String assertDesignDescription = fla.designDescription().getDesignDescription();
+
+ Assert.assertTrue((assertDesignDescription.contains(designDescription)),
+ "The description we've got is not accurate");
+
+
+
+ }
+
+ /**
+ * Adds license to design
+ *
+ */
+ @Test(dependsOnMethods={"addDesignDescription"})
+ public void addDesignLicense() {
+
+ final String licenseText = "LAMS Recommended: CC Attribution-Noncommercial-ShareAlike 2.5";
+
+ int licenseId = 1;
+ // sets license
+ String assertLicense = fla.designDescription().addDesignLicense(licenseId);
+
+ // close description UI component
+ fla.designDescription().closeDesignDescriptionDialog();
+
+ Assert.assertEquals(assertLicense, licenseText, "The license text does not match the expected one");
+
+ saveDesign();
+
+ }
+
+
+ /**
+ * Copy/Pastes an activity
+ *
+ */
+ @Test(dependsOnMethods={"addDesignLicense"})
+ public void copyPasteActivity() {
+
+ String copyOfActivity = "Copy of " + Q_AND_A_TITLE;
+ fla.copyPasteActivity(Q_AND_A_TITLE);
+
+ Boolean activityExists = fla.activityExists(copyOfActivity);
+
+ Assert.assertTrue(activityExists,
+ "Sorry, activity " + copyOfActivity + " doesn't exist in design.");
+
+ saveInvalidDesign();
+
+ }
+
+ /**
+ * Arranges design
+ *
+ */
+ @Test(dependsOnMethods={"copyPasteActivity"})
+ public void arrangeDesign() {
+
+ Point initialActivityLocation = fla.getActivityLocation(Q_AND_A_TITLE);
+
+ reArrangeDesign();
+
+ Point newActivityLocation = fla.getActivityLocation(Q_AND_A_TITLE);
+
+ Assert.assertFalse(initialActivityLocation.equals(newActivityLocation),
+ "The activity " + Q_AND_A_TITLE + " is still in the same location!" );
+
+ saveInvalidDesign();
+
+ }
+
+
+ /**
+ * Delete an activity
+ *
+ * This method is disabled as it seems that we can't drag and drop
+ * svg elements from one another
+ *
+ */
+ @Test(enabled = false, dependsOnMethods={"fixValidationAndSave"})
+ public void deleteActivity() {
+
+ String copyOfActivity = "Copy of " + Q_AND_A_TITLE;
+ fla.deleteActivity(copyOfActivity);
+
+ Boolean activityExists = fla.activityExists(copyOfActivity);
+
+ Assert.assertFalse(activityExists,
+ "Sorry, activity " + copyOfActivity + " still exists in design.");
+
+ }
+
+
+
+
+
}
Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/DescriptionPage.java
===================================================================
diff -u
--- lams_tests/tests/org/lamsfoundation/lams/pages/author/DescriptionPage.java (revision 0)
+++ lams_tests/tests/org/lamsfoundation/lams/pages/author/DescriptionPage.java (revision 54e27d396f92c7977bae72fc2e62598a6a8a1150)
@@ -0,0 +1,127 @@
+/****************************************************************
+ * 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.JavascriptExecutor;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+import org.openqa.selenium.support.FindBy;
+import org.openqa.selenium.support.ui.Select;
+
+/**
+ * Description Page within FLA for setting a general design description and license
+ *
+ * @author Ernie Ghiglione (ernieg@lamsfoundation.org)
+ *
+ */
+public class DescriptionPage extends AbstractPage {
+
+ @FindBy(id = "ldDescriptionHideTip")
+ private WebElement ldDescriptionHideTip;
+
+
+ @FindBy(id = "ldDescriptionLicenseSelect")
+ private WebElement ldDescriptionLicenseSelect;
+
+ public DescriptionPage(WebDriver driver) {
+ super(driver);
+
+ }
+
+
+ public FLAPage navigateToFLAPage() {
+ closeDesignDescriptionDialog();
+ return new FLAPage(driver);
+ }
+
+ /**
+ * Opens Description Dialog
+ *
+ */
+ public void openDesignDescriptionDialog() {
+
+ ldDescriptionHideTip.click();
+
+ }
+
+ /**
+ * Close Description Dialog
+ *
+ */
+ public void closeDesignDescriptionDialog() {
+
+ // toggles to open/close
+ openDesignDescriptionDialog();
+
+ }
+
+ /**
+ * Add description to CkEditor
+ *
+ * @param designDescription
+ */
+ public void addDesignDescription(String designDescription) {
+
+ // Insert text to CKEditor via javascript
+ ((JavascriptExecutor)
+ driver).executeScript("CKEDITOR.instances['ldDescriptionFieldDescription'].setData('" + designDescription +"');");
+
+
+
+ }
+
+ /**
+ * Selects a license from the dropdown menu
+ *
+ * @param licenseId
+ * @return text of the license selected
+ */
+ public String addDesignLicense(int licenseId) {
+
+ Select licenseDropDown = new Select(ldDescriptionLicenseSelect);
+ licenseDropDown.selectByIndex(licenseId);
+
+ return licenseDropDown.getFirstSelectedOption().getText();
+ }
+
+ /**
+ * Returns the design description entered
+ *
+ * @return string with description text
+ */
+ public String getDesignDescription() {
+
+ String getSetText = (String) ((JavascriptExecutor)
+ driver).executeScript("return (CKEDITOR.instances['ldDescriptionFieldDescription'].getData());");
+
+ return getSetText;
+
+
+ }
+
+
+}
Index: lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java
===================================================================
diff -u -r077b9d360fde841db54cae0b4df5db8ed3f4049e -r54e27d396f92c7977bae72fc2e62598a6a8a1150
--- lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 077b9d360fde841db54cae0b4df5db8ed3f4049e)
+++ lams_tests/tests/org/lamsfoundation/lams/pages/author/FLAPage.java (.../FLAPage.java) (revision 54e27d396f92c7977bae72fc2e62598a6a8a1150)
@@ -31,13 +31,15 @@
import org.lamsfoundation.lams.pages.AbstractPage;
import org.openqa.selenium.Alert;
import org.openqa.selenium.By;
+import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.ExpectedConditions;
+import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
/**
@@ -52,169 +54,187 @@
/**
* Menu buttons
* These are the menu buttons on the interface.
- */
-
+ */
+
@FindBy(id = "newButton")
private WebElement newButton;
-
+
@FindBy(id = "openButton")
private WebElement openButton;
-
- @FindBy(id = "importSequenceButton")
- private WebElement importSequenceButton;
-
- @FindBy(id = "importPartSequenceButton")
- private WebElement importPartSequenceButton;
+ @FindBy(id = "importDesignButton")
+ private WebElement importDesignButton;
+
+ @FindBy(id = "importPartDesignButton")
+ private WebElement importPartDesignButton;
+
@FindBy(id = "saveButton")
private WebElement saveButton;
-
+
@FindBy(id = "saveDropButton")
private WebElement saveDropButton;
-
+
@FindBy(id = "saveAsButton")
private WebElement saveAsButton;
-
+
@FindBy(id = "exportButton")
private WebElement exportButton;
-
-
+
+
@FindBy(id = "copyButton")
private WebElement copyButton;
-
+
@FindBy(id = "pasteButton")
private WebElement pasteButton;
-
+
@FindBy(id = "transitionButton")
private WebElement transitionButton;
-
+
@FindBy(id = "flowButton")
private WebElement flowButton;
-
+
@FindBy(id = "gateButton")
private WebElement gateButton;
-
+
@FindBy(id = "branchingButton")
private WebElement branchingButton;
-
+
@FindBy(id = "groupButton")
private WebElement groupButton;
-
+
@FindBy(id = "annotateButton")
private WebElement annotateButton;
-
+
@FindBy(id = "annotateLabelButton")
private WebElement annotateLabelButton;
-
+
@FindBy(id = "annotateRegionButton")
private WebElement annotateRegionButton;
-
+
@FindBy(id = "arrangeButton")
private WebElement arrangeButton;
-
+
@FindBy(id = "previewButton")
private WebElement previewButton;
-
+
/**
- * Activities
- */
-
-
+ * Activities
+ */
+
+
/**
- * Page elements
- * These are the page elements on FLA
- */
-
+ * Page elements
+ * These are the page elements on FLA
+ */
+
@FindBy(id = "canvas")
private WebElement canvas;
-
+
@FindBy(id = "ldDescriptionFieldTitle")
- private WebElement sequenceTitle;
-
+ private WebElement designTitle;
+
@FindBy(id = "svg")
private WebElement svgCanvas;
+
+ @FindBy(id = "rubbishBin")
+ private WebElement rubbishBin;
+
+
+ @FindBy(id = "ldDescriptionHideTip")
+ private WebElement designDescriptionLink;
-
/**
- * Dialogs: Save design dialog elements
- */
-
+ * Dialogs: Save design dialog elements
+ */
+
@FindBy(id = "ldStoreDialogNameField")
private WebElement ldStoreDialogNameField;
-
+
@FindBy(id = "saveLdStoreButton")
private WebElement saveLdStoreButton;
-
-
+
+
/**
- * Dialogs: Open design dialog elements
- */
-
+ * Dialogs: Open design dialog elements
+ */
+
@FindBy(id = "openLdStoreButton")
private WebElement openLdStoreButton;
-
+
@FindBy(id = "ldStoreDialogTreeCell")
private WebElement ldTree;
-
-
+
+
@FindBy(id = "propertiesContentTool")
private WebElement propertiesContentTool;
-
-
-
+
+
+
public FLAPage(WebDriver driver) {
super(driver);
-
+
}
-
-
-
+
+
+
/**
* Opens LD Dialog to open a design
*
*/
public void openLdOpenDialog() {
-
+
openButton.click();
}
-
+
/**
* Opens LD Dialog to save a design
*/
public void openLdSaveDialog() {
-
+
saveButton.click();
}
-
+
/**
* Clears canvas to new
*/
public void newDesign() {
-
+
newButton.click();
checkAlert();
}
/**
+ * Drops a group activity into the canvas.
+ *
+ */
+ public void dragGroupToCanvas() {
+
+ groupButton.click();
+ canvas.click();
+
+ }
+
+
+ /**
* Given the activity name, it drags it into the canvas. By default it puts it in the
* center of the canvas.
* @param name
*/
public void dragActivityToCanvas(String name) {
-
+
String toolName = "tool" + name;
-
- WebElement tool = driver.findElement(By.id(toolName));
-
- Actions builder = new Actions(driver); // Configure the Action
- Action dragAndDrop = builder.clickAndHold(tool)
- .moveToElement(canvas)
- .release(canvas)
- .build(); // Get the action
- dragAndDrop.perform(); // Execute the Action
-
+
+ WebElement tool = driver.findElement(By.id(toolName));
+
+ Actions builder = new Actions(driver); // Configure the Action
+ Action dragAndDrop = builder.clickAndHold(tool)
+ .moveToElement(canvas)
+ .release(canvas)
+ .build(); // Get the action
+ dragAndDrop.perform(); // Execute the Action
+
}
/**
@@ -227,25 +247,25 @@
* @param y y offset move
*/
public void dragActivityToCanvasPosition(String name, int x, int y) {
-
+
// we include the prefix "tool" as that's what we named the ids
String toolName = "tool" + name;
-
+
// Finds the activity
- WebElement tool = driver.findElement(By.id(toolName));
-
- // Prepare the dragAndDrop action
- Actions builder = new Actions(driver); // Configure the Action
- Action dragAndDrop = builder.clickAndHold(tool)
- .moveByOffset(x, y)
- .release()
- .build();
-
- // Execute the Action
- dragAndDrop.perform();
-
+ WebElement tool = driver.findElement(By.id(toolName));
+
+ // Prepare the dragAndDrop action
+ Actions builder = new Actions(driver); // Configure the Action
+ Action dragAndDrop = builder.clickAndHold(tool)
+ .moveByOffset(x, y)
+ .release()
+ .build();
+
+ // Execute the Action
+ dragAndDrop.perform();
+
}
-
+
/**
* Saves a design with the given param desigName.
*
@@ -254,74 +274,76 @@
*
*/
public String saveDesign(String designName) {
-
+
String saveResult = null;
openLdSaveDialog();
+ ldStoreDialogNameField.click();
+ ldStoreDialogNameField.clear();
ldStoreDialogNameField.sendKeys(designName);
saveLdStoreButton.click();
saveResult = getAlertText();
-
+
return saveResult;
-
+
}
-
+
/**
* Saves a design
* This takes no parameters as it's just a click on the
- * save menu button once the sequence/design exists.
+ * save menu button once the design exists.
*
* @return the message shown in the save alert popup.
*
*/
public String saveDesign() {
String saveResult = null;
-
+
saveButton.click();
saveResult = getAlertText();
-
+
return saveResult;
-
+
}
/**
- * Gets the Sequence title/name for the canvas.
+ * Gets the Design title/name for the canvas.
*
* @return
*/
- public String getSequenceName () {
- return sequenceTitle.getText().trim();
+ public String getDesignName () {
+ return designTitle.getText().trim();
}
-
+
/**
* Rearranges the design on the canvas by pressing
* the "Arrange" button.
*/
public void arrangeDesign() {
arrangeButton.click();
-
+
}
/**
- * Opens the open sequence dialog to select and open the design on
+ * Opens the open design dialog to select and open the design on
* canvas.
*
* @param seqName
*
*/
public void openDesign(String seqName) {
-
+
// opens the dialog
openLdOpenDialog();
-
- // parses the available sequences
+
+ // parses the available designs
List elements = ldTree.findElements(
By.xpath("//*[contains(text(), '"+ seqName +"')]"));
-
- // Find the sequence that is in seqName and also is visible
+
+ // Find the design that is in seqName and also is visible
// -- we've got to improve this though!
for (int i = 0; i < elements.size(); i++) {
WebElement el = elements.get(i);
@@ -330,10 +352,10 @@
el.click();
}
}
-
+
// click on open
openLdStoreButton.click();
-
+
}
@@ -343,25 +365,25 @@
*
*/
public void drawTransitionBtwActivities() {
-
+
WebElement svg = driver.findElement(By.tagName("svg"));
-
+
List listActivities = svg.findElements(By.tagName("text"));
-
+
int size = listActivities.size();
//System.out.println("Activity #: " + size);
for (int i = 0; i < size; i++) {
- System.out.println("i: " + i );
+ // System.out.println("i: " + i );
if (i+1 < size) {
transitionButton.click();
listActivities.get(i).click();
listActivities.get(i+1).click();
//System.out.println("i + 1= " + (i+1) );
-
+
}
//System.out.println("closing");
}
-
+
}
/**
@@ -371,11 +393,11 @@
* @param newActivityTitle
*/
public void changeActivityTitle(String activityTitle, String newActivityTitle) {
-
+
WebElement svg = driver.findElement(By.tagName("svg"));
-
+
WebElement activity = getActivityElement(svg, activityTitle);
-
+
// select the activity
activity.click();
@@ -387,10 +409,10 @@
driver.findElement(
By.xpath("/html/body/div[14]/div[2]/div/table/tbody/tr[1]/td[2]/input"))
.sendKeys(newActivityTitle);
-
+
// click on canvas so the change takes effect
canvas.click();
-
+
}
/**
@@ -403,73 +425,329 @@
*
*/
public AbstractPage openSpecificActivity(String activityName) {
-
+
WebElement svg = driver.findElement(By.tagName("svg"));
-
+
WebElement act = getActivityElement(svg, activityName);
-
+
Actions openAct = new Actions(driver);
openAct.doubleClick(act).build().perform();;
-
+
String popUpWindow = getPopUpWindowId(driver);
-
+
driver.switchTo().window(popUpWindow);
-
+
return PageFactory.initElements(driver, AbstractPage.class);
-
-
+
+
}
-
+
/**
* Given a design on canvas, it saves it under a new name
*
*
- * @param newSequenceName new name to save as
+ * @param newDesignName new name to save as
* @return msg from alert
*/
- public String saveAsDesign(String newSequenceName) {
-
+ public String saveAsDesign(String newDesignName) {
+
String saveAsResult = null;
saveDropButton.click();
saveAsButton.click();
+ ldStoreDialogNameField.click();
ldStoreDialogNameField.clear();
- ldStoreDialogNameField.sendKeys(newSequenceName);
+ ldStoreDialogNameField.sendKeys(newDesignName);
saveLdStoreButton.click();
saveAsResult = getAlertText();
-
+
return saveAsResult;
-
+
}
-
+
/**
* Gets the activity names into a list.
*
*
* @return a string list with the activity names
*/
public List getAllActivityNames() {
-
+
List allActivities = new ArrayList<>();
-
+
WebElement svg = driver.findElement(By.tagName("svg"));
-
+
List allActivitiesElements = getActivityElements(svg);
-
- System.out.println("Allactivities size: " + allActivitiesElements.size());
-
+
+ // System.out.println("Allactivities size: " + allActivitiesElements.size());
+
for (int i = 0; i < allActivitiesElements.size(); i++) {
-
+
WebElement element = allActivitiesElements.get(i);
- System.out.println(element.getText());
+ // System.out.println(element.getText());
allActivities.add(element.getText());
+
+ }
+
+ return allActivities;
+
+ }
+
+
+
+ /**
+ * Sets a group for an activity
+ * @param groupName the group to set to the activity
+ * @param activityName the activity
+ *
+ */
+ public void setGroupForActivity(String groupName, String activityName) {
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+
+ WebElement activity = getActivityElement(svg, activityName);
+
+ activity.click();
+
+ Select groupDropDown = new Select(
+ driver.findElement(
+ By.xpath("/html/body/div[14]/div[2]/div/table/tbody/tr[2]/td[2]/select")));
+ groupDropDown.selectByVisibleText(groupName);
+
+ canvas.click();
+
+
+ }
+
+
+
+ /**
+ * Draws a transition between two given activities
+ * @param fromActivity from activity name
+ * @param toActivity to activity name
+ */
+ public void drawTransitionFromTo(String fromActivity, String toActivity) {
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+
+ WebElement fromActivityElement = getActivityElement(svg, fromActivity);
+ WebElement toActivityElement = getActivityElement(svg, toActivity);
+
+ transitionButton.click();
+ fromActivityElement.click();
+ toActivityElement.click();
+
+ canvas.click();
+
+ }
+
+
+
+ /**
+ * Copy/pastes a given activity
+ * @param activity activity to copy/paste
+ */
+ public void copyPasteActivity(String activity) {
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+ // Select activity
+ getActivityElement(svg, activity).click();
+
+ copyButton.click();
+
+ pasteButton.click();
+
+
+
+ }
+
+
+ public Boolean activityExists(String activity) {
+
+ List activityNames = getAllActivityNames();
+
+ Boolean result = activityNames.contains(activity);
+
+ return result;
+ }
+
+
+
+ /**
+ * Throws an activity into the rubbish bin
+ *
+ * This method doesn't seem to be working as selenium seems to
+ * have some issues when moving things around with SVG.
+ *
+ * @param activity
+ */
+ public void deleteActivity(String activity) {
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+ // Select activity
+ WebElement activityToDelete = getActivityElement(svg, activity);
+
+ activityToDelete.click();
+
+ WebElement bin = svg.findElement(By.id("rubbishBin"));
+
+ Actions builder = new Actions(driver);
+ Action binActivityAction = builder.clickAndHold(activityToDelete)
+ .moveToElement(bin)
+ .release(bin)
+ .build(); // Get the action
+
+ binActivityAction.perform(); // Execute the Action
+
+ }
+
+
+
+ /**
+ * Sets/modifies the group setting for a group activity
+ *
+ * @param groupActivityName group to be set/modified
+ * @param groupType group type choice (random, monitor, learner)
+ * @param isGroupsOrLearners true = groups , false = learners
+ * @param numberOfGroups number of groups/learners
+ * @param groupNames group names ie: "Group 01, Group 02, ..."
+ * @param groupOptions group options
+ * ie: "boolean equalGroups, boolean viewLearnersBeforeSelection"
+ */
+ public void setGroups(String groupActivityName, String groupType, boolean isGroupsOrLearners,
+ int numberOfGroups, String groupNames, String groupOptions) {
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+ // Select activity
+ WebElement groupActivity = getActivityElement(svg, groupActivityName);
+
+ groupActivity.click();
+
+ switch (groupType) {
+ case "random":
+
+ // Set grouping type to random
+ setGroupType(groupType);
+
+ // Determine if group Groups or groups Learners
+ setGroupOrLearners(numberOfGroups, isGroupsOrLearners);
+
+
+ break;
+ case "monitor":
+
+ // Set grouping type to random
+ setGroupType(groupType);
+
+ // set GroupGroups
+ setGroupNumber(numberOfGroups, isGroupsOrLearners);
+ break;
+
+ case "learner":
+
+ // Set grouping type to random
+ setGroupType(groupType);
+
+ // Determine if group Groups or groups Learners
+ setGroupOrLearners(numberOfGroups, isGroupsOrLearners);
+
+ // Now if there's extra options for learners choice grouping
+ if (!(groupOptions == null || groupOptions.trim().equals(""))) {
+ String[] options = groupOptions.split(",");
+
+ // set equal group size
+ if (options[0].equals("true")) {
+ WebElement equalGroupSizes =
+ driver.findElement(
+ By.xpath("/html/body/div[14]/div[2]/div/table/tbody/tr[5]/td[2]/input"));
+
+ equalGroupSizes.click();
+
+ }
+
+ // set view learners before selection
+ if (options[1].equals("true")) {
+ WebElement viewLearnersBeforeSelection =
+ driver.findElement(
+ By.xpath("/html/body/div[14]/div[2]/div/table/tbody/tr[6]/td[2]/input"));
+
+ viewLearnersBeforeSelection.click();
+
+ }
+
+
+ }
+
+
+ break;
+
+ default:
+ break;
}
+
+ // If we the group names are given then add them
+ if (!(groupNames == null || groupNames.trim().equals(""))) {
+
+ setGroupNames(groupNames);
+
+ }
+
+ // Click on canvas to remove focus and set values
+ canvas.click();
+
+ }
- return allActivities;
+
+ /**
+ * Design description UI component
+ *
+ * @return DescriptionPage object
+ */
+ public DescriptionPage designDescription() {
+
+ return PageFactory.initElements(driver, DescriptionPage.class);
+
}
+
+
+ public String getGroupType(String groupActivityName) {
+ final String selectGroupDropDownXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[2]/td[2]/select";
+
+ WebElement svg = driver.findElement(By.tagName("svg"));
+ // Select activity
+ WebElement groupActivity = getActivityElement(svg, groupActivityName);
+
+ groupActivity.click();
+
+
+ // Set grouping type to random
+ Select groupDropDown = new Select(
+ driver.findElement(
+ By.xpath(selectGroupDropDownXpath)));
+
+ String groupType = groupDropDown.getFirstSelectedOption().getAttribute("value");
+
+ return groupType;
+ }
+ /**
+ * Returns the location for a given activity
+ *
+ * @param activityTitle
+ * @return Point location for the activity
+ */
+ public Point getActivityLocation(String activityTitle) {
+ WebElement svg = driver.findElement(By.tagName("svg"));
+ // Select activity
+ WebElement activity = getActivityElement(svg, activityTitle);
+
+ return activity.getLocation();
+ }
+
+
/**
* Returns the correct popup id
@@ -478,30 +756,30 @@
* @return
*/
private String getPopUpWindowId(WebDriver driver) {
-
+
String authorToolWindow = null;
Set handles = driver.getWindowHandles();
Iterator iterator = handles.iterator();
-
+
while (iterator.hasNext()){
- authorToolWindow = iterator.next();
+ authorToolWindow = iterator.next();
}
-
+
return authorToolWindow;
}
/**
* Clicks OK on the alert javascript popup
*/
private void checkAlert() {
- try {
- WebDriverWait wait = new WebDriverWait(driver, 2);
- wait.until(ExpectedConditions.alertIsPresent());
- Alert alert = driver.switchTo().alert();
- alert.accept();
- } catch (Exception e) {
- //exception handling
- }
+ try {
+ WebDriverWait wait = new WebDriverWait(driver, 2);
+ wait.until(ExpectedConditions.alertIsPresent());
+ Alert alert = driver.switchTo().alert();
+ alert.accept();
+ } catch (Exception e) {
+ //exception handling
+ }
}
/**
@@ -510,22 +788,22 @@
* @return text from popup
*/
private String getAlertText() {
-
+
String txt = null;
-
- try {
- WebDriverWait wait = new WebDriverWait(driver, 2);
- wait.until(ExpectedConditions.alertIsPresent());
- Alert alert = driver.switchTo().alert();
- txt = alert.getText();
- //driver.switchTo().defaultContent();
- alert.accept();
- } catch (Exception e) {
- //exception handling
- }
- return txt;
+
+ try {
+ WebDriverWait wait = new WebDriverWait(driver, 2);
+ wait.until(ExpectedConditions.alertIsPresent());
+ Alert alert = driver.switchTo().alert();
+ txt = alert.getText();
+ //driver.switchTo().defaultContent();
+ alert.accept();
+ } catch (Exception e) {
+ //exception handling
+ }
+ return txt;
}
-
+
/**
* Parses thru the SVG design to find the WebElement for the activity name.
*
@@ -534,22 +812,22 @@
* @return
*/
private WebElement getActivityElement(WebElement svg, String activityName) {
-
+
WebElement activityElement = null;
-
+
List listActivities = svg.findElements(By.tagName("text"));
-
+
for (WebElement webElement : listActivities) {
activityElement = webElement.findElement(By.tagName("tspan"));
String name = activityElement.getText();
-
+
if (activityName.equals(name)) {
break;
-
+
}
-
+
}
-
+
return activityElement;
}
@@ -560,19 +838,121 @@
* @return list of web elements for activities in design
*/
private List getActivityElements(WebElement svg) {
-
+
List activitiesElements = new ArrayList();
-
+
List activityList = svg.findElements(By.tagName("text"));
-
+
for (WebElement webElement : activityList) {
WebElement activityElement = webElement.findElement(By.tagName("tspan"));
activitiesElements.add(activityElement);
}
-
+
return activitiesElements;
+
+ }
+
+
+ /**
+ * Add group names to group activity
+ *
+ * @param groupNames
+ */
+ private void setGroupNames(String groupNames) {
+ final String nameGroupButtonXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[7]/td/div/span";
+ final String okButtonXpath =
+ "/html/body/div[15]/div[11]/div/button[1]/span";
+ // open naming groups dialog
+ WebElement nameGroupButton = driver.findElement(
+ By.xpath(nameGroupButtonXpath));
+
+ nameGroupButton.click();
+
+ // populate group names:
+ String[] listGroupNames = groupNames.split(",");
+ //System.out.println(listGroupNames.length);
+
+ int i = 1;
+ for (String groupName : listGroupNames) {
+
+ WebElement inputElement = driver.findElement(
+ By.xpath("/html/body/div[15]/div[2]/input[" + Integer.toString(i) + "]"));
+
+ inputElement.clear();
+ inputElement.sendKeys(groupName);
+ i++;
+
+ }
+
+ WebElement okButton = driver.findElement(
+ By.xpath(okButtonXpath));
+
+ okButton.click();
}
+
+ /**
+ * Sets the group type
+ *
+ * @param groupType
+ */
+ private void setGroupType(String groupType) {
+ final String selectGroupDropDownXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[2]/td[2]/select";
+
+ // Set grouping type to random
+ Select groupDropDown = new Select(
+ driver.findElement(
+ By.xpath(selectGroupDropDownXpath)));
+ groupDropDown.selectByValue(groupType);
+
+ }
+
+ private void setGroupOrLearners(int numberOfGroups, boolean groupsOrLearners) {
+ final String radioNumberOfGroupsXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[3]/td[2]/input";
+ final String radioNumberOfLearnersXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[4]/td[2]/input";
+
+ String elementXpath = (groupsOrLearners) ? radioNumberOfGroupsXpath : radioNumberOfLearnersXpath;
+
+ // Set Group to group number
+ WebElement radioGroups =
+ driver.findElement(
+ By.xpath(elementXpath));
+
+ radioGroups.click();
+
+ setGroupNumber(numberOfGroups, groupsOrLearners);
+
+ }
+ /**
+ * Sets the group number or the number of learners per group
+ *
+ * @param numberOfGroups
+ * @param groupsOrLearners
+ */
+ private void setGroupNumber(int numberOfGroups, Boolean groupsOrLearners) {
+ final String inputNumGroupXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[3]/td[2]/span/input";
+ final String inputNumLearnerXpath =
+ "/html/body/div[14]/div[2]/div/table/tbody/tr[4]/td[2]/span/input";
+
+ String elementXpath = (groupsOrLearners) ? inputNumGroupXpath : inputNumLearnerXpath;
+
+ // Get input for number of groups
+ WebElement inputNumGroups = driver.findElement(
+ By.xpath(elementXpath));
+
+ //System.out.println("xpath: " + elementXpath);
+ // set numb groups
+ inputNumGroups.clear();
+ inputNumGroups.sendKeys(Integer.toString(numberOfGroups));
+ }
+
+
+
}