Browse Source

add new changes

purigarcia 10 years ago
parent
commit
aa9abc55b4

+ 9 - 1
automationTest/pom.xml

@@ -20,6 +20,15 @@
     			</includes>
   			</configuration>
 		</plugin>
+		<plugin>
+        	<groupId>org.apache.maven.plugins</groupId>
+        	<artifactId>maven-compiler-plugin</artifactId>
+        	<version>3.3</version>
+        	<configuration>
+          	<source>1.7</source>
+          	<target>1.7</target>
+        </configuration>
+      </plugin>
       </plugins>
     </pluginManagement>
   </build>
@@ -66,5 +75,4 @@
     	<scope>provided</scope>
   </dependency>
 </dependencies>
-
 </project>

+ 18 - 0
automationTest/src/test/java/androidtest/tests/Common.java

@@ -1,14 +1,24 @@
 package androidtest.tests;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URL;
+import java.text.SimpleDateFormat;
+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;
@@ -84,4 +94,12 @@ public class Common extends TestCase{
 		throw new TimeoutException();
 	}
 	
+	protected void takeScreenShotOnFailed (String testName) throws IOException {
+		File file  = ((RemoteWebDriver) driver).getScreenshotAs(OutputType.FILE);
+		SimpleDateFormat dt1 = new SimpleDateFormat("yyyy-MM-dd");
+		Date today = Calendar.getInstance().getTime(); 
+		String screenShotName = "ScreenShots/" + dt1.format(today) + "/" + testName + ".png";
+		FileUtils.copyFile(file, new File(screenShotName));
+	}
+
 }

+ 2 - 1
automationTest/src/test/java/androidtest/tests/CreateFolderTestSuite.java

@@ -5,6 +5,7 @@ import org.junit.Before;
 import org.junit.runners.MethodSorters;
 import org.junit.FixMethodOrder;
 import org.junit.Test;
+
 import androidtest.actions.Actions;
 import androidtest.models.MainView;
 import androidtest.models.WaitAMomentPopUp;
@@ -17,7 +18,6 @@ public class CreateFolderTestSuite extends Common{
 	private final String FOLDER_NAME = "testCreateFolder";
 	private String CurrentCreatedFolder = "";
 
-
 	@Before
 	public void setUp() throws Exception {
 		setUpCommonDriver();
@@ -44,6 +44,7 @@ public class CreateFolderTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		if (folderHasBeenCreated) {
 			MainView mainView = new MainView(driver);
 			Actions.deleteElement(CurrentCreatedFolder, mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/DeleteFileTestSuite.java

@@ -40,6 +40,7 @@ public class DeleteFileTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		driver.removeApp("com.owncloud.android");
 		driver.quit();
 	}

+ 1 - 0
automationTest/src/test/java/androidtest/tests/DeleteFolderTestSuite.java

@@ -41,6 +41,7 @@ public class DeleteFolderTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		if(folderHasBeenCreated){
 			MainView mainView = new MainView(driver);
 			Actions.deleteElement(FOLDER_NAME, mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/LoginTestSuite.java

@@ -88,6 +88,7 @@ public class LoginTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		driver.removeApp("com.owncloud.android");
 		driver.quit();
 	}

+ 1 - 0
automationTest/src/test/java/androidtest/tests/LogoutTestSuite.java

@@ -33,6 +33,7 @@ public class LogoutTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		driver.removeApp("com.owncloud.android");
 		driver.quit();
 	}

+ 1 - 0
automationTest/src/test/java/androidtest/tests/MoveFileTestSuite.java

@@ -67,6 +67,7 @@ public class MoveFileTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		MainView mainView = new MainView(driver);
 		driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
 		Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/MoveFolderTestSuite.java

@@ -66,6 +66,7 @@ public class MoveFolderTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		MainView mainView = new MainView(driver);
 		driver.sendKeyEvent(android.view.KeyEvent.KEYCODE_BACK);
 		Actions.deleteElement(FOLDER_WHERE_MOVE, mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/RenameFileTestSuite.java

@@ -59,6 +59,7 @@ public class RenameFileTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		if (fileHasBeenCreated) {
 			MainView mainView = new MainView(driver);
 			Actions.deleteElement(CurrentCreatedFile,mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/RenameFolderTestSuite.java

@@ -57,6 +57,7 @@ public class RenameFolderTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		if(folderHasBeenCreated){
 			MainView mainView = new MainView(driver);
 			Actions.deleteElement(CurrentCreatedFolder, mainView, driver);

+ 1 - 0
automationTest/src/test/java/androidtest/tests/UploadTestSuite.java

@@ -70,6 +70,7 @@ public class UploadTestSuite extends Common{
 
 	@After
 	public void tearDown() throws Exception {
+		takeScreenShotOnFailed(getName());
 		MainView mainView = new MainView(driver);
 		Actions.deleteElement(FILE_NAME,mainView, driver);
 		driver.removeApp("com.owncloud.android");