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
;
14 import org
.openqa
.selenium
.By
;
15 import org
.openqa
.selenium
.support
.ui
.ExpectedConditions
;
17 import androidtest
.actions
.Actions
;
18 import androidtest
.groups
.NoIgnoreTestCategory
;
19 import androidtest
.groups
.SmokeTestCategory
;
20 import androidtest
.models
.ElementMenuOptions
;
21 import androidtest
.models
.MainView
;
22 import androidtest
.models
.NewFolderPopUp
;
23 import androidtest
.models
.WaitAMomentPopUp
;
26 @FixMethodOrder(MethodSorters
.NAME_ASCENDING
)
27 public class RenameFileTestSuite
{
31 private Boolean fileHasBeenCreated
= false
;
32 private final String OLD_FILE_NAME
= "test";
33 private final String FILE_NAME
= "newNameFile";
34 private String CurrentCreatedFile
= "";
36 @Rule public TestName name
= new TestName();
39 public void setUp() throws Exception
{
41 driver
=common
.setUpCommonDriver();
45 @Category({NoIgnoreTestCategory
.class, SmokeTestCategory
.class})
46 public void testRenameFile () throws Exception
{
47 MainView mainView
= Actions
.login(Config
.URL
, Config
.user
,Config
.password
, Config
.isTrusted
, driver
);
48 common
.assertIsInMainView();
50 //TODO. if the file already exists, do not upload
51 MainView mainViewAfterUploadFile
= Actions
.uploadFile(OLD_FILE_NAME
, mainView
);
53 //check if the file with the new name already exists, if true delete it
54 Actions
.deleteElement(FILE_NAME
, mainView
, driver
);
56 mainViewAfterUploadFile
.scrollTillFindElement(OLD_FILE_NAME
);
57 assertTrue(fileHasBeenCreated
= mainViewAfterUploadFile
.getFileElement().isDisplayed());
58 CurrentCreatedFile
= OLD_FILE_NAME
;
59 Common
.waitTillElementIsNotPresent(mainViewAfterUploadFile
.getProgressCircular(), 1000);
60 common
.wait
.until(ExpectedConditions
.visibilityOf(mainViewAfterUploadFile
.getFileElementLayout().findElement(By
.id(MainView
.getLocalFileIndicator()))));
61 ElementMenuOptions menuOptions
= mainViewAfterUploadFile
.longPressOnElement(OLD_FILE_NAME
);
62 NewFolderPopUp newFolderPopUp
= menuOptions
.clickOnRename();
63 newFolderPopUp
.typeNewFolderName(FILE_NAME
);
64 WaitAMomentPopUp waitAMomentPopUp
= newFolderPopUp
.clickOnNewFolderOkButton();
65 Common
.waitTillElementIsNotPresent(waitAMomentPopUp
.getWaitAMomentTextElement(), 100);
66 mainViewAfterUploadFile
.scrollTillFindElement(FILE_NAME
);
67 assertNotNull(mainViewAfterUploadFile
.getFileElement());
68 assertTrue(mainViewAfterUploadFile
.getFileElement().isDisplayed());
69 assertEquals(FILE_NAME
, mainViewAfterUploadFile
.getFileElement().getText());
70 CurrentCreatedFile
= FILE_NAME
;
74 public void tearDown() throws Exception
{
75 common
.takeScreenShotOnFailed(name
.getMethodName());
76 if (fileHasBeenCreated
) {
77 MainView mainView
= new MainView(driver
);
78 Actions
.deleteElement(CurrentCreatedFile
,mainView
, driver
);
80 driver
.removeApp("com.owncloud.android");