X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/ba1470a9884507fa57b2b01fdb9c601f52587b83..aa9abc55b4195e3dadd8f0985322e4f49b88c4b9:/automationTest/src/test/java/androidtest/tests/Common.java diff --git a/automationTest/src/test/java/androidtest/tests/Common.java b/automationTest/src/test/java/androidtest/tests/Common.java index 7bf21bdc..c457d20a 100644 --- a/automationTest/src/test/java/androidtest/tests/Common.java +++ b/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)); + } + }