-/target/
-src/test/java/androidtest/tests/Config.java
+
+target/
+ScreenShots/
+++ /dev/null
-eclipse.preferences.version=1
-encoding//src/main/java=UTF-8
-encoding//src/test/java=UTF-8
-encoding/<project>=UTF-8
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
- <version>2.1.0</version>
+ <version>2.2.0</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
import java.util.HashMap;
import org.openqa.selenium.NoSuchElementException;
+import org.openqa.selenium.ScreenOrientation;
import org.openqa.selenium.remote.RemoteWebElement;
import io.appium.java_client.android.AndroidDriver;
LoginForm loginForm = new LoginForm(driver);
CertificatePopUp certificatePopUp = loginForm.typeHostUrl(url);
if(!isTrusted){
- driver.runAppInBackground(3);
WebDriverWait wait = new WebDriverWait(driver, 30);
- wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement()));
- certificatePopUp.clickOnOkButton();
+ //sometimes the certificate has been already accept and it doesn't appear again
+ try {
+ wait.until(ExpectedConditions.visibilityOf(certificatePopUp.getOkButtonElement()));
+ //we need to repaint the screen because of some element are misplaced
+ driver.rotate(ScreenOrientation.LANDSCAPE);
+ driver.rotate(ScreenOrientation.PORTRAIT);
+ certificatePopUp.clickOnOkButton();
+ }catch (NoSuchElementException e) {
+
+ }
+
}
loginForm.typeUserName(user);
loginForm.typePassword(password);
AndroidElement fileElement;
WaitAMomentPopUp waitAMomentPopUp;
try{
+ //To open directly the "file list view" and we don't need to know in which view we are
+ driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
fileElement = (AndroidElement) driver.findElementByName(elementName);
ElementMenuOptions menuOptions = mainView.longPressOnElement(elementName);
RemoveConfirmationView removeConfirmationView = menuOptions.clickOnRemove();;
final AndroidDriver driver;
+ @AndroidFindBy(name = "Share link")
+ private AndroidElement shareLinkElement;
+
@AndroidFindBy(name = "Details")
private AndroidElement detailsFileElement;
NewFolderPopUp newFolderPopUp = new NewFolderPopUp(driver);
return newFolderPopUp;
}
+
+ public ShareView clickOnShareLinkElement () {
+ shareLinkElement.click();
+ ShareView shareView = new ShareView(driver);
+ return shareView;
+ }
}
public void typeUserName (String userName) {
userNameInput.clear();
- userNameInput.sendKeys(userName);
- driver.hideKeyboard();
+ //using the \n , it not need to hide the keyboard which sometimes gives problems
+ userNameInput.sendKeys(userName + "\n");
+ //driver.hideKeyboard();
}
public void typePassword (String password) {
passwordInput.clear();
- passwordInput.sendKeys(password);
- driver.hideKeyboard();
+ passwordInput.sendKeys(password + "\n");
+ //driver.hideKeyboard();
}
public MainView clickOnConnectButton () {
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
+import io.appium.java_client.android.AndroidKeyCode;
import io.appium.java_client.pagefactory.AndroidFindBy;
import io.appium.java_client.pagefactory.AppiumFieldDecorator;
import org.openqa.selenium.support.CacheLookup;
import org.openqa.selenium.support.PageFactory;
+import org.openqa.selenium.Point;
import androidtest.actions.Actions;
public class MainView {
@AndroidFindBy(name = "Files")
private AndroidElement filesElementUploadFile;
+ @CacheLookup
+ @AndroidFindBy(uiAutomator = "new UiSelector().description(\"List Layout\")")
+ private AndroidElement listLayout;
+
private AndroidElement fileElement;
private AndroidElement fileElementLayout;
}
public MenuList clickOnMenuButton () {
- menuButton.click();
+ //if the menu option is not in the actionBar, it is opening again
+ try {
+ menuButton.click();
+ } catch (NoSuchElementException e){
+ driver.sendKeyEvent(AndroidKeyCode.MENU);
+ }
MenuList menuList = new MenuList (driver);
return menuList;
}
return titleText;
}
+ public AndroidElement getUploadButton () {
+ return uploadButton;
+ }
+
public AndroidElement getWaitAMomentTextElement () {
return waitAMomentText;
}
public static String getFavoriteFileIndicator() {
return favoriteFileIndicator;
}
+
+ public void pulldownToRefresh () throws InterruptedException {
+ Point listLocation = listLayout.getLocation();
+ driver.swipe(listLocation.getX(),listLocation.getY(), listLocation.getX(),listLocation.getY()+1000, 5000);
+ }
}
public void typeNewFolderName (String newFolderName) {
newFolderNameField.clear();
- newFolderNameField.sendKeys(newFolderName);
- driver.hideKeyboard();
+ newFolderNameField.sendKeys(newFolderName + "\n");
+ //driver.hideKeyboard();
}
public WaitAMomentPopUp clickOnNewFolderOkButton () {
public class SettingsView {
final AndroidDriver driver;
-
+
@CacheLookup
@AndroidFindBy(name = Config.userAccount)
private AndroidElement accountElement;
-
+
@CacheLookup
@AndroidFindBy(name = Config.userAccount2)
private AndroidElement accountElement2;
-
+
@AndroidFindBy(name = "Delete account")
private AndroidElement deleteAccountElement;
-
+
@AndroidFindBy(name = "Change password")
private AndroidElement changePasswordElement;
-
+
@AndroidFindBy(name = "Add account")
private AndroidElement addAccountElement;
-
+
+ @AndroidFindBy(uiAutomator = "new UiSelector().className(\"android.widget.CheckBox\").index(0)")
+ private AndroidElement passcodeCheckbox;
+
public SettingsView (AndroidDriver driver) {
this.driver = driver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);
public void tapOnAccountElement (int fingers, int milliSeconds) {
accountElement.tap(fingers, milliSeconds);
}
-
-
+
+
public void tapOnAddAccount (int fingers, int milliSeconds) {
addAccountElement.tap(fingers, milliSeconds);
}
-
+
public LoginForm clickOnDeleteAccountElement () {
deleteAccountElement.click();
LoginForm loginForm = new LoginForm(driver);
return loginForm;
}
-
+
public LoginForm clickOnChangePasswordElement () {
changePasswordElement.click();
LoginForm loginForm = new LoginForm(driver);
return loginForm;
}
+
+ public PassCodeView EnablePassCode(){
+ if(!passcodeCheckbox.isSelected()){
+ passcodeCheckbox.click();
+ }
+ PassCodeView passcodeview = new PassCodeView(driver);
+ return passcodeview;
+ }
+ public PassCodeView DisablePassCode(){
+ if(passcodeCheckbox.isSelected()){
+ passcodeCheckbox.click();
+ }
+ PassCodeView passcodeview = new PassCodeView(driver);
+ return passcodeview;
+ }
+
}
package androidtest.tests;
+import static org.junit.Assert.*;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.TimeUnit;
-
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TimeoutException;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.remote.Augmenter;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.support.ui.WebDriverWait;
-
import io.appium.java_client.android.AndroidDriver;
import io.appium.java_client.android.AndroidElement;
-import junit.framework.TestCase;
-public class Common extends TestCase{
+public class Common{
AndroidDriver driver;
static int waitingTime = 30;
-
+
WebDriverWait wait;
-
- protected void setUpCommonDriver () throws Exception {
+
+ protected AndroidDriver setUpCommonDriver () throws Exception {
File rootPath = new File(System.getProperty("user.dir"));
File appDir = new File(rootPath,"src/test/resources");
File app = new File(appDir,"ownCloud.apk");
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("platformName", "Android");
- capabilities.setCapability("deviceName", "Device");
+ capabilities.setCapability("deviceName", "test");
capabilities.setCapability("app", app.getAbsolutePath());
- capabilities.setCapability("app-package", "com.owncloud.android");
- capabilities.setCapability("app-activity", ".ui.activity.FileDisplayActivity");
+ capabilities.setCapability("appPackage", "com.owncloud.android");
+ capabilities.setCapability("appActivity", ".ui.activity.FileDisplayActivity");
capabilities.setCapability("appWaitActivity", ".authentication.AuthenticatorActivity");
driver = new AndroidDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(waitingTime, TimeUnit.SECONDS);
wait = new WebDriverWait(driver, waitingTime, 50);
+ return driver;
}
-
+
protected boolean waitForTextPresent(String text, AndroidElement element) throws InterruptedException{
for (int second = 0;;second++){
if (second >= waitingTime)
if (text.equals(element.getText()))
break;
} catch (Exception e){
-
+
}
Thread.sleep(1000);
}
return true;
}
-
+
protected boolean isElementPresent(AndroidElement element, By by) {
try {
element.findElement(by);
return false;
}
}
-
+
protected boolean isElementPresent(AndroidElement element) {
try{
element.isDisplayed();
}
return true;
}
-
+
//pollingTime in milliseconds
public static void waitTillElementIsNotPresent (AndroidElement element, int pollingTime) throws Exception {
for (int time = 0;;time += pollingTime){
}
throw new TimeoutException();
}
-
+
protected void takeScreenShotOnFailed (String testName) throws IOException {
File file = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE);
SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
FileUtils.copyFile(file, new File(screenShotName));
}
+ protected void assertIsInMainView() throws InterruptedException {
+ assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")")));
+ assertTrue(isElementPresent((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")")));
+ }
+
+ protected void assertIsNotInMainView() throws InterruptedException {
+ AndroidElement fileElement;
+ assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")")));
+ try {
+ fileElement = (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().description(\"Upload\")");
+ } catch (NoSuchElementException e) {
+ fileElement = null;
+ }
+ assertNull(fileElement);
+ }
+
+ protected void assertIsPasscodeRequestView() throws InterruptedException {
+ assertTrue(waitForTextPresent("ownCloud", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")")));
+ assertTrue(((AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().text(\"Please, insert your pass code\")")).isDisplayed());
+
+ }
+
+ protected void assertIsInSettingsView() throws InterruptedException {
+ assertTrue(waitForTextPresent("Settings", (AndroidElement) driver.findElementByAndroidUIAutomator("new UiSelector().resourceId(\"android:id/action_bar_title\")")));
+ }
+
}
package androidtest.tests;
public final class Config {
-
- public static final String server = "owncloudServerVar";
- public static final Boolean hasResource = false;
- public static String URL = GetURl(server, hasResource, "resourceServerVar");
+
+ //without http or https
+ public static final String URL = "owncloudServerVar";
public static boolean isTrusted = true;
-
- public static final String server2 = "owncloudServer2Var";
- public static final Boolean hasResource2 = false;
- public static String URL2 = GetURl(server2, hasResource2, "resourceServerVar");
+
+ //without http or https
+ public static final String URL2 = "owncloudServer2Var";
public static boolean isTrusted2 = true;
-
+
public static final String user = "owncloudUserVar";
public static final String password = "owncloudPasswordVar";
public static final String user2 = "owncloudUser2Var";
public static final String password2 = "owncloudPassword2Var";
- public static final String userAccount = user + "@"+ server;
- public static final String userAccount2 = user2 + "@"+ server2;
-
- public static String GetURl(String server, Boolean hasSubdirectory, String serverResource){
- if(hasSubdirectory){
- return server + serverResource;
- }else{
- return server;
- }
- }
+ public static final String userAccount = user + "@"+ URL;
+ public static final String userAccount2 = user2 + "@"+ URL2;
+
}
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.MainView;
import androidtest.models.WaitAMomentPopUp;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class CreateFolderTestSuite extends Common{
+public class CreateFolderTestSuite{
+ AndroidDriver driver;
+ Common common;
private Boolean folderHasBeenCreated = false;
private final String FOLDER_NAME = "testCreateFolder";
private String CurrentCreatedFolder = "";
+
+ @Rule public TestName name = new TestName();
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testCreateNewFolder () throws Exception {
String NEW_FOLDER_NAME = "testCreateFolder";
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
//check if the folder already exists and if true, delete them
Actions.deleteElement(NEW_FOLDER_NAME, mainView, driver);
WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(NEW_FOLDER_NAME, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_NAME);
assertNotNull(mainView.getFileElement());
assertTrue(folderHasBeenCreated=mainView.getFileElement().isDisplayed());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
if (folderHasBeenCreated) {
MainView mainView = new MainView(driver);
Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.openqa.selenium.support.ui.ExpectedConditions;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.MainView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class DeleteFileTestSuite extends Common{
+public class DeleteFileTestSuite{
+ AndroidDriver driver;
+ Common common;
private final String FILE_NAME = "test";
+ @Rule public TestName name = new TestName();
+
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testDeleteFile () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+ common.assertIsInMainView();
//TODO. if the file already exists, do not upload
MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
- waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
- wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+ Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+ common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
Actions.deleteElement(FILE_NAME,mainViewAfterUploadFile, driver);
assertFalse(mainViewAfterUploadFile.getFileElement().isDisplayed());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
driver.removeApp("com.owncloud.android");
driver.quit();
}
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.MainView;
import androidtest.models.WaitAMomentPopUp;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class DeleteFolderTestSuite extends Common{
+public class DeleteFolderTestSuite{
+ AndroidDriver driver;
+ Common common;
private Boolean folderHasBeenCreated = false;
private final String FOLDER_NAME = "testCreateFolder";
+
+ @Rule public TestName name = new TestName();
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testDeleteFolder () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+ common.assertIsInMainView();
//TODO. if the folder already exists, do no created
//create the folder
WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(FOLDER_NAME, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_NAME);
assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
if(folderHasBeenCreated){
MainView mainView = new MainView(driver);
Actions.deleteElement(FOLDER_NAME, mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.openqa.selenium.ScreenOrientation;
import androidtest.actions.Actions;
+import androidtest.groups.*;
import androidtest.models.LoginForm;
import androidtest.models.MainView;
import androidtest.models.MenuList;
import androidtest.models.SettingsView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class LoginTestSuite extends Common{
-
+public class LoginTestSuite{
+ AndroidDriver driver;
+ Common common;
+
+ @Rule public TestName name = new TestName();
+
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class})
public void test1LoginPortrait () throws Exception {
driver.rotate(ScreenOrientation.PORTRAIT);
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
}
@Test
+ @Category({NoIgnoreTestCategory.class})
public void test2LoginLandscape () throws Exception {
driver.rotate(ScreenOrientation.LANDSCAPE);
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
- //TO DO. detect in which view is. it can be files view or settings view
+ common.assertIsInMainView();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void test3MultiAccountRotate () throws Exception {
driver.rotate(ScreenOrientation.LANDSCAPE);
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
driver.rotate(ScreenOrientation.PORTRAIT);
MenuList menu = mainView.clickOnMenuButton();
SettingsView settingsView = menu.clickOnSettingsButton();
+
settingsView.tapOnAddAccount(1, 1000);
mainView = Actions.login(Config.URL2, Config.user2,Config.password2, Config.isTrusted2, driver);
-
- assertTrue(waitForTextPresent("Settings", mainView.getTitleTextElement()));
- //TO DO. detect in which view is. it can be files view or settings view
- //Actions.deleteAccount(mainView);
- //TO DO. Delete the second user
+ common.assertIsInSettingsView();
}
@Test
+ @Category({NoIgnoreTestCategory.class})
public void test4ExistingAccountRotate () throws Exception {
driver.rotate(ScreenOrientation.PORTRAIT);
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
driver.rotate(ScreenOrientation.LANDSCAPE);
MenuList menu = mainView.clickOnMenuButton();
LoginForm loginForm = new LoginForm(driver);
mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText()));
+ assertTrue(common.waitForTextPresent("An account for the same user and server already exists in the device", loginForm.getAuthStatusText()));
}
-
+ @Test
+ @Category({NoIgnoreTestCategory.class})
public void test5ChangePasswordWrong () throws Exception {
-
+ driver.rotate(ScreenOrientation.PORTRAIT);
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
MenuList menu = mainView.clickOnMenuButton();
SettingsView settingsView = menu.clickOnSettingsButton();
settingsView.tapOnAccountElement(1, 1000);
LoginForm changePasswordForm = settingsView.clickOnChangePasswordElement();
changePasswordForm.typePassword("WrongPassword");
changePasswordForm.clickOnConnectButton();
- assertTrue(waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
+ assertTrue(common.waitForTextPresent("Wrong username or password", changePasswordForm.getAuthStatusText()));
}
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
driver.removeApp("com.owncloud.android");
driver.quit();
}
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.LoginForm;
import androidtest.models.MainView;
import androidtest.models.MenuList;
import androidtest.models.SettingsView;
-public class LogoutTestSuite extends Common{
+public class LogoutTestSuite{
+
+ AndroidDriver driver;
+ Common common;
+ @Rule public TestName name = new TestName();
+
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testLogout () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+ common.assertIsInMainView();
MenuList menulist = mainView.clickOnMenuButton();
SettingsView settingsView = menulist.clickOnSettingsButton();
settingsView.tapOnAccountElement(1, 1000);
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
- driver.removeApp("com.owncloud.android");
+ common.takeScreenShotOnFailed(name.getMethodName());
+ //driver.removeApp("com.owncloud.android");
driver.quit();
}
}
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
import org.junit.FixMethodOrder;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.ElementMenuOptions;
import androidtest.models.MainView;
import androidtest.models.MoveView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class MoveFileTestSuite extends Common{
+public class MoveFileTestSuite{
+ AndroidDriver driver;
+ Common common;
private String FOLDER_WHERE_MOVE = "folderWhereMove";
private String FILE_NAME = "test";
-
+ @Rule public TestName name = new TestName();
+
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testMoveFile () throws Exception {
WaitAMomentPopUp waitAMomentPopUp;
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
- waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+ Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
//check if the folder already exists and if true, delete them
Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
//Create the folder where the other is gone to be moved
waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
assertTrue(mainView.getFileElement().isDisplayed());
//to move to a folder
moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
waitAMomentPopUp = moveView.clickOnChoose();
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
//check that the folder moved is inside the other
mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
- waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+ Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
Thread.sleep(1000);
mainView.scrollTillFindElement(FILE_NAME);
assertEquals(FILE_NAME , mainView.getFileElement().getText());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
MainView mainView = new MainView(driver);
driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
+
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.ElementMenuOptions;
import androidtest.models.MainView;
import androidtest.models.MoveView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class MoveFolderTestSuite extends Common{
+public class MoveFolderTestSuite{
+ AndroidDriver driver;
+ Common common;
private String FOLDER_TO_MOVE = "folderToMove";
private String FOLDER_WHERE_MOVE = "folderWhereMove";
+
+ @Rule public TestName name = new TestName();
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testMoveFolder () throws Exception {
WaitAMomentPopUp waitAMomentPopUp;
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
- waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+ Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
//check if the folder already exists and if true, delete them
Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
//Create the folder where the other is gone to be moved
waitAMomentPopUp = Actions.createFolder(FOLDER_WHERE_MOVE, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_WHERE_MOVE);
assertTrue(mainView.getFileElement().isDisplayed());
//Create the folder which is going to be moved
waitAMomentPopUp = Actions.createFolder(FOLDER_TO_MOVE, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_TO_MOVE);
assertTrue(mainView.getFileElement().isDisplayed());
//to move to a folder
moveView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
waitAMomentPopUp = moveView.clickOnChoose();
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
//check that the folder moved is inside the other
mainView.scrollTillFindElement(FOLDER_WHERE_MOVE).tap(1,1);
- waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+ Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
Thread.sleep(1000);
mainView.scrollTillFindElement(FOLDER_TO_MOVE);
assertEquals(FOLDER_TO_MOVE , mainView.getFileElement().getText());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
MainView mainView = new MainView(driver);
driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.openqa.selenium.support.ui.ExpectedConditions;
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.ElementMenuOptions;
import androidtest.models.MainView;
import androidtest.models.NewFolderPopUp;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class RenameFileTestSuite extends Common{
+public class RenameFileTestSuite{
+ AndroidDriver driver;
+ Common common;
private Boolean fileHasBeenCreated = false;
private final String OLD_FILE_NAME = "test";
private final String FILE_NAME = "newNameFile";
private String CurrentCreatedFile = "";
-
+
+ @Rule public TestName name = new TestName();
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testRenameFile () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+ common.assertIsInMainView();
//TODO. if the file already exists, do not upload
MainView mainViewAfterUploadFile = Actions.uploadFile(OLD_FILE_NAME, mainView);
mainViewAfterUploadFile.scrollTillFindElement(OLD_FILE_NAME);
assertTrue(fileHasBeenCreated = mainViewAfterUploadFile.getFileElement().isDisplayed());
CurrentCreatedFile = OLD_FILE_NAME;
- waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
- wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+ Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+ common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
ElementMenuOptions menuOptions = mainViewAfterUploadFile.longPressOnElement(OLD_FILE_NAME);
NewFolderPopUp newFolderPopUp = menuOptions.clickOnRename();
newFolderPopUp.typeNewFolderName(FILE_NAME);
WaitAMomentPopUp waitAMomentPopUp = newFolderPopUp.clickOnNewFolderOkButton();
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
assertNotNull(mainViewAfterUploadFile.getFileElement());
assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
if (fileHasBeenCreated) {
MainView mainView = new MainView(driver);
Actions.deleteElement(CurrentCreatedFile,mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
+import io.appium.java_client.android.AndroidDriver;
+
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
+
import androidtest.actions.Actions;
+import androidtest.groups.NoIgnoreTestCategory;
+import androidtest.groups.SmokeTestCategory;
import androidtest.models.ElementMenuOptions;
import androidtest.models.MainView;
import androidtest.models.NewFolderPopUp;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class RenameFolderTestSuite extends Common{
+public class RenameFolderTestSuite{
+ AndroidDriver driver;
+ Common common;
private Boolean folderHasBeenCreated = false;
private final String OLD_FOLDER_NAME = "beforeRemoving";
private final String FOLDER_NAME = "testCreateFolder";
private String CurrentCreatedFolder = "";
+
+ @Rule public TestName name = new TestName();
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
+ @Category({NoIgnoreTestCategory.class, SmokeTestCategory.class})
public void testRenameFolder () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- waitForTextPresent("ownCloud", mainView.getTitleTextElement());
+ common.assertIsInMainView();
//TODO. if the folder already exists, do no created
//create the folder to rename
WaitAMomentPopUp waitAMomentPopUp = Actions.createFolder(OLD_FOLDER_NAME, mainView);
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(OLD_FOLDER_NAME);
assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
FolderPopUp.typeNewFolderName(FOLDER_NAME);
FolderPopUp.clickOnNewFolderOkButton();
CurrentCreatedFolder = FOLDER_NAME;
- waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
+ Common.waitTillElementIsNotPresent(waitAMomentPopUp.getWaitAMomentTextElement(), 100);
mainView.scrollTillFindElement(FOLDER_NAME);
assertNotNull(mainView.getFileElement());
assertTrue(folderHasBeenCreated = mainView.getFileElement().isDisplayed());
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
if(folderHasBeenCreated){
MainView mainView = new MainView(driver);
Actions.deleteElement(CurrentCreatedFolder, mainView, driver);
package androidtest.tests;
+import static org.junit.Assert.*;
import io.appium.java_client.MobileBy;
+import io.appium.java_client.android.AndroidDriver;
import org.junit.After;
import org.junit.Before;
+import org.junit.Rule;
+import org.junit.experimental.categories.Category;
+import org.junit.rules.TestName;
import org.junit.runners.MethodSorters;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.openqa.selenium.support.ui.ExpectedConditions;
import androidtest.actions.Actions;
+import androidtest.groups.FailingTestCategory;
+import androidtest.groups.IgnoreTestCategory;
+import androidtest.groups.NoIgnoreTestCategory;
import androidtest.models.AppDetailsView;
import androidtest.models.ElementMenuOptions;
+import androidtest.models.GmailEmailListView;
+import androidtest.models.GmailEmailView;
+import androidtest.models.ImageView;
import androidtest.models.MainView;
+import androidtest.models.UploadView;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
-public class UploadTestSuite extends Common{
+@Category({NoIgnoreTestCategory.class})
+public class UploadTestSuite{
+ AndroidDriver driver;
+ Common common;
String FILE_NAME = "test";
+
+ @Rule public TestName name = new TestName();
+
@Before
public void setUp() throws Exception {
- setUpCommonDriver();
+ common=new Common();
+ driver=common.setUpCommonDriver();
}
@Test
- public void test1UploadFile () throws Exception {
+ @Category(NoIgnoreTestCategory.class)
+ public void testUploadFile () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
//check if the file already exists and if true, delete it
Actions.deleteElement(FILE_NAME, mainView, driver);
mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
assertTrue(mainViewAfterUploadFile.getFileElement().isDisplayed());
- waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
- wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
+ Common.waitTillElementIsNotPresent(mainViewAfterUploadFile.getProgressCircular(), 1000);
+ common.wait.until(ExpectedConditions.visibilityOf(mainViewAfterUploadFile.getFileElementLayout().findElement(By.id(MainView.getLocalFileIndicator()))));
}
-
+
@Test
- public void test2KeepFileUpToDate () throws Exception {
+ @Category(IgnoreTestCategory.class)
+ public void testUploadFromGmail () throws Exception {
+ MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
+ driver.startActivity("com.google.android.gm", ".ConversationListActivityGmail");
+ GmailEmailListView gmailEmailListView = new GmailEmailListView(driver);
+ GmailEmailView gmailEmailView = gmailEmailListView.clickOnEmail();
+ ImageView imageView = gmailEmailView.clickOnfileButton();
+ imageView.clickOnOptionsButton();
+ imageView.clickOnShareButton();
+ imageView.clickOnOwnCloudButton();
+ imageView.clickOnJustOnceButton();
+ UploadView uploadView = new UploadView(driver);
+ uploadView.clickOUploadButton();
+ driver.startActivity("com.owncloud.android", ".ui.activity.FileDisplayActivity");
+ common.wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.name("test.jpg")));
+ assertEquals("test.jpg" , driver.findElementByName("test.jpg").getText());
+ }
+
+
+ @Test
+ @Category({IgnoreTestCategory.class, FailingTestCategory.class})
+ public void testKeepFileUpToDate () throws Exception {
MainView mainView = Actions.login(Config.URL, Config.user,Config.password, Config.isTrusted, driver);
- assertTrue(waitForTextPresent("ownCloud", mainView.getTitleTextElement()));
+ common.assertIsInMainView();
- waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
+ Common.waitTillElementIsNotPresent(mainView.getProgressCircular(), 1000);
MainView mainViewAfterUploadFile = Actions.uploadFile(FILE_NAME, mainView);
mainViewAfterUploadFile.scrollTillFindElement(FILE_NAME);
appDetailsView.checkKeepFileUpToDateCheckbox();
Thread.sleep(3000);
driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
- assertTrue(isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator())));
+ assertTrue(common.isElementPresent(mainViewAfterUploadFile.getFileElementLayout(), MobileBy.id(MainView.getFavoriteFileIndicator())));
}
@After
public void tearDown() throws Exception {
- takeScreenShotOnFailed(getName());
+ common.takeScreenShotOnFailed(name.getMethodName());
MainView mainView = new MainView(driver);
Actions.deleteElement(FILE_NAME,mainView, driver);
driver.removeApp("com.owncloud.android");