UploadTestSuite.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package androidtest.tests;
  2. import io.appium.java_client.MobileBy;
  3. import org.junit.After;
  4. import org.junit.Before;
  5. import org.junit.runners.MethodSorters;
  6. import org.junit.FixMethodOrder;
  7. import org.junit.Test;
  8. import org.openqa.selenium.By;
  9. import org.openqa.selenium.support.ui.ExpectedConditions;
  10. import androidtest.actions.Actions;
  11. import androidtest.models.AppDetailsView;
  12. import androidtest.models.ElementMenuOptions;
  13. import androidtest.models.MainView;
  14. @FixMethodOrder(MethodSorters.NAME_ASCENDING)
  15. public class UploadTestSuite extends Common{
  16. String FILE_NAME = "test";
  17. @Before
  18. public void setUp() throws Exception {
  19. setUpCommonDriver();
  20. }
  21. @Test
  22. public void test1UploadFile () throws Exception {
  23. MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
  24. assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
  25. //check if the file already exists and if true, delete it
  26. Actions.deleteElement(FILE_NAME, mainView, driver);
  27. MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
  28. mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
  29. assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
  30. waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
  31. wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
  32. }
  33. @Test
  34. public void test2KeepFileUpToDate () throws Exception {
  35. MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
  36. assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
  37. waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
  38. MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
  39. mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
  40. assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
  41. ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(FILE_NAME);
  42. AppDetailsView appDetailsView = menuOptions.clickOnDetails();
  43. appDetailsView.checkKeepFileUpToDateCheckbox();
  44. Thread.sleep(3000);
  45. driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
  46. assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator())));
  47. }
  48. @After
  49. public void tearDown() throws Exception {
  50. MainView mainView = new MainView(driver);
  51. Actions.deleteElement(FILE_NAME,mainView, driver);
  52. driver.removeApp("com.owncloud.android");
  53. driver.quit();
  54. }
  55. }