--- /dev/null
+/*
+ * Copyright 2011 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client.selenium.folder;
+
+import org.openqa.selenium.By;
+import org.openqa.selenium.Keys;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.WebElement;
+
+
+public class ActionUtils {
+
+ private final WebDriver driver;
+
+ public ActionUtils(WebDriver aDriver) {
+ this.driver = aDriver;
+
+ }
+
+ /**
+ * Opens the application url and wait some secs
+ * @param aUrl
+ */
+
+ public void getUrl(String aUrl){
+ driver.get(aUrl);
+
+ }
+
+ public void click(By locator) {
+ driver.findElement(locator).click();
+
+ }
+
+ public void submit(By locator) {
+ driver.findElement(locator).submit();
+
+ }
+ /**
+ * Type something into an input field. WebDriver doesn't normally clear these
+ * before typing, so this method does that first. It also sends a return key
+ * to move the focus out of the element.
+ */
+ public void type(By locator, String text) {
+ WebElement element = driver.findElement(locator);
+ element.clear();
+ //element.sendKeys(text + "\n");
+ element.sendKeys(text);
+
+ }
+
+ public void sendRightClick(By locator) {
+ WebElement element = driver.findElement(locator);
+ element.sendKeys(Keys.chord(Keys.SHIFT,Keys.F10));
+
+ }
+
+ public String getText(By locator){
+ WebElement element = driver.findElement(locator);
+ return element.getText();
+
+ }
+
+ public void quit() throws InterruptedException{
+ Thread.sleep(2000);
+ driver.quit();
+
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2011 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.client.selenium.folder;
+
+
+import junit.framework.Assert;
+import junit.framework.AssertionFailedError;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.firefox.FirefoxDriver;
+
+
+public class TestFolder {
+
+ ActionUtils action;
+
+ WebDriver driver;
+
+ String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/";
+
+ String folderName = "Alderaan";
+
+ String userName = "past@ebs.gr";
+
+ /**
+ * Initialize the driver, the actionUtils, the application's url
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+
+ driver = new FirefoxDriver();
+
+ action = new ActionUtils(driver);
+
+ action.getUrl(url);
+
+ // Necessary delay in order all dom elements to be created
+ Thread.sleep(10000);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ action.quit();
+ }
+
+ /**
+ * Select the user's home folder
+ *
+ * @param aUserName
+ */
+ private void selectHomeFolder(String aUserName){
+ action.click(By.id(aUserName));
+ }
+
+ /**
+ * Select any folder below the user's home folder
+ *
+ * @param aUserName
+ * @param aFolderName
+ */
+ private void selectFolderBelowHome(String aUserName, String aFolderName){
+ action.click(By.id(aUserName+ "." + aFolderName));
+ }
+
+ /**
+ * Select the Trash folder
+ */
+ private void selectTrash(){
+ action.click(By.id("Trash"));
+ }
+
+ /**
+ * Select the My Shared folder
+ */
+ private void selectMyShared(){
+ action.click(By.id("My Shared"));
+ }
+
+ /**
+ * Select the Other's Shared folder
+ */
+ private void selectOthersShared(){
+ action.click(By.id("others"));
+ }
+
+ private void expandTree(){
+// ERROR: Compound class names are not supported. Consider searching for one class name and filtering the results.
+// action.click(By.className("GK31MSKBDF GK31MSKBLF"));
+ action.click(By.xpath("//span[@id='My Shared']../../.."));
+// action.click(By.xpath("//div[@id='']/img"));
+ }
+
+ /**
+ * Create a new folder under the root folder
+ * @param aFolderName
+ * @throws InterruptedException
+ */
+ private void makeNewFolder(String aUserName, String aFolderName) throws InterruptedException{
+ //Click the home folder
+ selectHomeFolder(aUserName);
+
+ //Click the top file menu
+ action.click(By.id("topMenu.file"));
+
+ Thread.sleep(1000);
+
+ //Click the New Folder option from the file menu
+ action.click(By.id("topMenu.file.newFolder"));
+
+ Thread.sleep(1000);
+
+ //In the popup dialog click on the Name textBox and type the folder name
+ action.type(By.id("folderPropertiesDialog.textBox.name"), aFolderName);
+
+ //Submit
+ action.click(By.id("folderPropertiesDialog.button.ok"));
+
+ }
+
+ /**
+ * Delete a folder with the given folderName
+ * that lies below the root folder
+ *
+ * @param aFolderName
+ */
+ private void deleteFolder(String aUserName, String aFolderName){
+ //Click the home folder
+ selectFolderBelowHome(aUserName, aFolderName);
+
+ //Click top edit menu
+ action.click(By.id("topMenu.edit"));
+
+
+ //Click move to trash option
+ action.click(By.id("topMenu.edit.delete"));
+
+ //Click ok button in the confirmation dialog box
+ action.click(By.id("confirmation.ok"));
+
+ }
+ /**
+ * Moving a folder which lies under the root folder to trash folder
+ *
+ * @param aFolderName
+ */
+ private void moveToTrash(String aUserName, String aFolderName){
+ //Click the home folder
+ selectFolderBelowHome(aUserName, aFolderName);
+
+ //Click top edit menu
+ action.click(By.id("topMenu.edit"));
+
+ //Click move to trash option
+ action.click(By.id("topMenu.edit.moveToTrash"));
+
+ }
+
+ /**
+ * Emptying the trash folder using right click action
+ *
+ * @throws InterruptedException
+ */
+ private void emptyTrash() throws InterruptedException{
+
+ selectTrash();
+
+ action.sendRightClick(By.id("Trash"));
+
+// Thread.sleep(8000);
+
+ //Select emptyTrash from context menu
+ action.click(By.id("folderContextMenu.emptyTrash"));
+
+ }
+
+ @Test
+ public void testMakeNewFolder() throws InterruptedException{
+ //Create the folder with the given folderName
+ makeNewFolder(userName, folderName);
+
+ System.out.println(action.getText(By.id("past@ebs.gr."+folderName)));
+
+ //the test is the folder exists
+ Assert.assertEquals(folderName, action.getText(By.id("past@ebs.gr."+folderName)));
+
+ }
+
+ @Test
+ public void testDeleteFolder(){
+
+ selectFolderBelowHome(userName, folderName);
+
+ //Delete the folder
+ deleteFolder(userName, folderName);
+
+ }
+
+ @Test (expected=org.openqa.selenium.NoSuchElementException.class)
+ public void testMakeNewFolderAndDelete() throws InterruptedException{
+
+ //Create the folder with the given folderName
+ makeNewFolder(userName, folderName);
+
+ //Necessary delay
+ Thread.sleep(2000);
+
+ //Delete the folder
+ deleteFolder(userName, folderName);
+
+ //the test is successful if that condition fails
+ Assert.assertEquals(folderName, action.getText(By.id("past@ebs.gr."+folderName)));
+
+ }
+
+ @Test
+ public void testCreateFolderAndMoveToTrash() throws InterruptedException{
+ //Create a new folder
+ makeNewFolder(userName, folderName);
+
+ //Necessary delay
+ Thread.sleep(2000);
+
+ //Move to Trash
+ moveToTrash(userName, folderName);
+
+ /**
+ * TODO: In order to confirm that
+ * the new folder exists in Trash folder
+ * trash folder should be expanded first
+ * and then select the element
+ */
+
+ }
+
+ @Test
+ public void testCreateFolderAndMoveToTrashAndEmptyTrash() throws InterruptedException{
+
+ //Create a new folder
+ makeNewFolder(userName, folderName);
+
+ //Necessary delay
+ Thread.sleep(3000);
+
+ //Move to Trash
+ moveToTrash(userName, folderName);
+
+ emptyTrash();
+
+ /**
+ * TODO: In order to confirm that
+ * the new folder exists in Trash folder
+ * trash folder should be expanded first
+ * and then select the element
+ */
+
+ }
+
+ /**
+ * Method that tries to expand the '+' symbol
+ * in order to reveal folder's containing folders
+ */
+ @Test
+ public void testExpand(){
+ selectMyShared();
+
+ expandTree();
+ }
+
+}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.openqa.selenium.By;
-import org.openqa.selenium.Keys;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
-
-
-public class ActionFactory {
-
- private static Log logger = LogFactory.getLog(ActionFactory.class);
-
- private final WebDriver driver;
-
- public ActionFactory(WebDriver aDriver) {
- this.driver = aDriver;
-
- }
-
- /**
- * Opens the application url and wait some secs
- * @param aUrl
- */
-
- public void getUrl(String aUrl){
- try{
- driver.get(aUrl);
- }catch(Exception e){
- logger.debug("Could not open the application url " + aUrl);
- e.printStackTrace();
- }
-
- }
-
- public void click(By locator) {
- try{
- driver.findElement(locator).click();
- }catch(Exception e){
- logger.debug("Cound not locate " + locator.toString());
- e.printStackTrace();
- }
-
- }
-
- public void submit(By locator) {
- try{
- driver.findElement(locator).submit();
- }catch(Exception e){
- logger.debug("Cound not submit " + locator.toString());
- e.printStackTrace();
- }
-
- }
- /**
- * Type something into an input field. WebDriver doesn't normally clear these
- * before typing, so this method does that first. It also sends a return key
- * to move the focus out of the element.
- */
- public void type(By locator, String text) {
- try{
- WebElement element = driver.findElement(locator);
- element.clear();
- //element.sendKeys(text + "\n");
- element.sendKeys(text);
-
- }catch(Exception e){
- logger.debug("Cound not sendKeys " +text + " to " + locator.toString());
- e.printStackTrace();
- }
-
- }
-
- public void sendRightClick(By locator) {
- try{
- WebElement element = driver.findElement(locator);
- element.sendKeys(Keys.chord(Keys.SHIFT,Keys.F10));
-
- }catch(Exception e){
- logger.debug("Cound not send Right Click "+ " to " + locator.toString());
- e.printStackTrace();
- }
-
- }
- public String getText(By locator){
- try{
- WebElement element = driver.findElement(locator);
- return element.getText();
-
- }catch(Exception e){
- e.printStackTrace();
- }
- return null;
- }
-
- public void quit(){
- try{
- Thread.sleep(2000);
- driver.quit();
- }catch(Exception e){
- logger.debug("Could not quit driver");
- e.printStackTrace();
- }
-
- }
-
-
-
-}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxDriver;
-
-
-public class CreateFolderAndDelete {
-
- public static void main(String[] args) throws InterruptedException{
-
- WebDriver driver = new FirefoxDriver();
-
- ActionFactory action = new ActionFactory(driver);
-
- String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/";
-
- String folderName = "Alderaan";
-
- //Create a new folder
- NewFolder newFolder = new NewFolder(action, driver);
-
- action.getUrl(url);
-
- // Necessary delay in order all dom elements to be created
- Thread.sleep(4000);
-
- newFolder.makeNewFolder(folderName);
-
- System.out.println("Successful CREATION of " + folderName);
-
- // Necessary delay in order the page to be refreshed
- Thread.sleep(3000);
-
- //Delete the folder
- DeleteFolder delete = new DeleteFolder(action, driver);
-
- delete.deleteFolder(folderName);
-
- System.out.println("Successful DELETION of " + folderName);
-
- action.quit();
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.firefox.FirefoxDriver;
-
-public class CreateFolderAndMoveToTrash {
-
- public static void main(String[] args) throws InterruptedException{
-
- WebDriver driver = new FirefoxDriver();
-
- ActionFactory action = new ActionFactory(driver);
-
- String url = "http://127.0.0.1:8080/pithos/login?next=http://127.0.0.1:8080/pithos/";
-
- String folderName = "Tatooine2";
-
- //Create a new folder
- NewFolder newFolder = new NewFolder(action, driver);
-
- action.getUrl(url);
-
- // Necessary delay in order all dom elements to be created
- Thread.sleep(4000);
-
- newFolder.makeNewFolder(folderName);
-
- System.out.println("Successful CREATION of " + folderName);
-
- // Necessary delay in order the page to be refreshed
- Thread.sleep(3000);
-
- //Move to Trash
- MoveToTrash move = new MoveToTrash(action, driver);
-
- move.moveToTrash(folderName);
-
- Thread.sleep(3000);
-
- move.emptyTrash();
-
-
- action.quit();
- }
-}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-
-
-/**
- * @author natasa
- *
- */
-public class DeleteFolder {
-
- private static Log logger = LogFactory.getLog(DeleteFolder.class);
-
- private ActionFactory action;
-
-
- public DeleteFolder(ActionFactory anAction, WebDriver aDriver){
- action = anAction;
- action = new ActionFactory(aDriver);
-
- }
-
- public void deleteFolder(String aFolderName){
- try{
- //Click the home folder
- action.click(By.id("past@ebs.gr." + aFolderName));
-
- //Click top edit menu
- action.click(By.id("topMenu.edit"));
-
-
- //Click move to trash option
- action.click(By.id("topMenu.edit.delete"));
-
- //Click ok button in the confirmation dialog box
- action.click(By.id("confirmation.ok"));
-
- }catch(Exception e){
- logger.debug("Deletion of " + aFolderName + "FAILED");
- e.printStackTrace();
- }
-
- }
-
- public String checkDeletion(String aFolderName){
- try{
- action.click(By.id("past@ebs.gr." + aFolderName));
- return("Deletion of '" + aFolderName + "' FAILED!!!");
- }catch(Exception e){
- e.printStackTrace();
- return("SUCCESSful deletion of " + aFolderName);
- }
-
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-
-
-
-public class MoveToTrash {
-
- private static Log logger = LogFactory.getLog(NewFolder.class);
-
- private ActionFactory action;
-
- String folderName;
-
- public MoveToTrash(ActionFactory anAction, WebDriver aDriver){
- action = anAction;
- action = new ActionFactory(aDriver);
- }
-
- public void moveToTrash(String aFolderName){
- try{
- //Click the home folder
- action.click(By.id("past@ebs.gr." + aFolderName));
-
- //Click top edit menu
- action.click(By.id("topMenu.edit"));
-
- //Click move to trash option
- action.click(By.id("topMenu.edit.moveToTrash"));
-
- logger.info("SUCCESS");
-
- }catch(Exception e){
- logger.debug("Deletion of " + aFolderName + "FAILED");
- e.printStackTrace();
- }
-
- }
-
- public void emptyTrash(){
- try{
- Thread.sleep(1000);
- //Click the home folder
- action.click(By.id("Trash"));
-
- action.sendRightClick(By.id("Trash"));
-
- System.out.println("Send Right click");
- Thread.sleep(5000);
- //Select emptyTrash from context menu
- action.click(By.id("folderContextMenu.emptyTrash"));
-
- logger.debug("SUCCESS");
-
- }catch(Exception e){
- logger.debug("Empty trash FAILED");
- e.printStackTrace();
- }
- }
-
-}
+++ /dev/null
-/*
- * Copyright 2011 Electronic Business Systems Ltd.
- *
- * This file is part of GSS.
- *
- * GSS is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * GSS 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 GSS. If not, see <http://www.gnu.org/licenses/>.
- */
-package gr.ebs.gss.client.selenium.webDriver;
-
-
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-
-
-
-public class NewFolder {
-
- private static Log logger = LogFactory.getLog(NewFolder.class);
-
- private ActionFactory action;
-
- String folderName;
-
- /**
- * @param aDriver
- */
- public NewFolder(ActionFactory anAction, WebDriver aDriver){
- action = anAction;
- action = new ActionFactory(aDriver);
- }
-
- public void makeNewFolder(String aFolderName){
-
- try{
- //Click the home folder
- action.click(By.id("past@ebs.gr"));
-
- //Click the top file menu
- action.click(By.id("topMenu.file"));
-
- //Click the New Folder option from the file menu
- action.click(By.id("topMenu.file.newFolder"));
-
- //In the popup dialog click on the Name textBox and type the folder name
- action.type(By.id("folderPropertiesDialog.textBox.name"), aFolderName);
-
- //Submit
- action.click(By.id("folderPropertiesDialog.button.ok"));
-
- }catch(Exception e){
- logger.debug("The creation of a new folder didn't succeeded");
- e.printStackTrace();
- }
- }
-
- public String checkNewFolder(String aFolderName){
- String res = action.getText(By.id("past@ebs.gr." + aFolderName));
- if(res == null){
- return ("Creation of the folder " + aFolderName + "FAILED!!");
- }
- return ("SUCCESSful creation of " + res);
-
- }
-
- public void quit(){
- action.quit();
- }
-
-}