1 package androidtest
.tests
;
3 import static org
.junit
.Assert
.*;
4 import io
.appium
.java_client
.android
.AndroidDriver
;
6 import org
.junit
.After
;
7 import org
.junit
.Before
;
9 import org
.junit
.experimental
.categories
.Category
;
10 import org
.junit
.rules
.TestName
;
11 import org
.junit
.runners
.MethodSorters
;
12 import org
.junit
.FixMethodOrder
;
13 import org
.junit
.Test
;
15 import androidtest
.actions
.Actions
;
16 import androidtest
.groups
.NoIgnoreTestCategory
;
17 import androidtest
.groups
.SmokeTestCategory
;
18 import androidtest
.models
.ElementMenuOptions
;
19 import androidtest
.models
.MainView
;
20 import androidtest
.models
.NewFolderPopUp
;
21 import androidtest
.models
.WaitAMomentPopUp
;
24 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
25 public class RenameFolderTestSuite
{
29 private Boolean folderHasBeenCreated
= false
;
30 private final String OLD_FOLDER_NAME
= "beforeRemoving";
31 private final String FOLDER_NAME
= "testCreateFolder";
32 private String CurrentCreatedFolder
= "";
34 @Rule public TestName name
= new TestName();
38 public void setUp() throws Exception
{
40 driver
=common
.setUpCommonDriver();
44 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
45 public void testRenameFolder () throws Exception
{
46 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
47 common
.assertIsInMainView();
49 //TODO. if the folder already exists, do no created
50 //create the folder to rename
51 WaitAMomentPopUp waitAMomentPopUp
= Actions
.createFolder(OLD_FOLDER_NAME
, mainView
);
52 Common
.waitTillElementIsNotPresent(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
53 mainView
.scrollTillFindElement(OLD_FOLDER_NAME
);
55 assertTrue(folderHasBeenCreated
= mainView
.getFileElement().isDisplayed());
57 //check if the folder with the new name already exists and if true, delete them
58 Actions
.deleteElement(FOLDER_NAME
, mainView
, driver
);
60 CurrentCreatedFolder
= OLD_FOLDER_NAME
;
61 ElementMenuOptions menuOptions
= mainView
.longPressOnElement(OLD_FOLDER_NAME
);
62 NewFolderPopUp FolderPopUp
= menuOptions
.clickOnRename();
63 FolderPopUp
.typeNewFolderName(FOLDER_NAME
);
64 FolderPopUp
.clickOnNewFolderOkButton();
65 CurrentCreatedFolder
= FOLDER_NAME
;
66 Common
.waitTillElementIsNotPresent(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
67 mainView
.scrollTillFindElement(FOLDER_NAME
);
68 assertNotNull(mainView
.getFileElement());
69 assertTrue(folderHasBeenCreated
= mainView
.getFileElement().isDisplayed());
70 assertEquals(FOLDER_NAME
, mainView
.getFileElement().getText());
74 public void tearDown() throws Exception
{
75 common
.takeScreenShotOnFailed(name
.getMethodName());
76 if(folderHasBeenCreated
){
77 MainView mainView
= new MainView(driver
);
78 Actions
.deleteElement(CurrentCreatedFolder
, mainView
, driver
);
80 driver
.removeApp("com.owncloud.android");