From 83fe885241349f2e479753b0452746874c35cc24 Mon Sep 17 00:00:00 2001 From: faleev Date: Fri, 31 Oct 2014 14:00:13 +0200 Subject: [PATCH 1/3] Improve Allure reporting. Command [mvn -fae clean test && mvn site --non-recursive] - will create report in the folder testing-example-java/target/site/allure-maven-plugin. --- pom.xml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 88a6dc4..eb38ec8 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,7 @@ testing-example-java pom 1.0-SNAPSHOT + https://github.com/faleev/testing-example-java unit-tests wsdl-tests @@ -17,6 +18,8 @@ Test Execution Results testng.xml false + 1.7.4 + UTF-8 @@ -71,7 +74,7 @@ ru.yandex.qatools.allure allure-testng-adaptor - 1.4.0 + 1.4.3 junit @@ -108,6 +111,9 @@ ${project.basedir} ${project.basedir}/target/reports + + -javaagent:${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar + @@ -142,6 +148,11 @@ ru.yandex.qatools.allure allure-maven-plugin 2.0 + + 1.4.3 + **/allure-results + ${project.reporting.outputDirectory}/allure-maven-plugin + From d09cdc503bf86d23629f4e128fd6b33af3a29ee7 Mon Sep 17 00:00:00 2001 From: faleev Date: Fri, 31 Oct 2014 14:01:02 +0200 Subject: [PATCH 2/3] Add ability to attach Webdriver screenshots to the Allure report. --- .../com/example/selenium/common/Page.java | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/selenium-tests/src/main/java/com/example/selenium/common/Page.java b/selenium-tests/src/main/java/com/example/selenium/common/Page.java index af8f02a..b1819b1 100644 --- a/selenium-tests/src/main/java/com/example/selenium/common/Page.java +++ b/selenium-tests/src/main/java/com/example/selenium/common/Page.java @@ -1,19 +1,11 @@ package com.example.selenium.common; -import com.example.utils.ProjectConfiguration; -import org.apache.commons.io.FileUtils; import org.openqa.selenium.*; import org.openqa.selenium.support.PageFactory; import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; -import org.testng.Reporter; - -import java.io.File; -import java.io.IOException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Date; +import ru.yandex.qatools.allure.annotations.Attachment; public abstract class Page { @@ -73,19 +65,24 @@ public Boolean apply(WebDriver driver){ wait.until(ajaxCompletion); } - public static void takeScreenshot(WebDriver driver) { - // Known issue: ChromeDriver2 take screenshot is not full page - // (https://code.google.com/p/chromedriver/issues/detail?id=294) - File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); - DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); - String screenshotsDirictory = ProjectConfiguration.getProperty("screenshots.directory.location") + "/screenshots"; - new File(screenshotsDirictory).mkdirs(); - String screenshotFilename = dateFormat.format(new Date()) + ".png"; - try { - FileUtils.copyFile(screenshot, new File(screenshotsDirictory + "/" + screenshotFilename)); - } catch (IOException e) { - e.printStackTrace(); - } - Reporter.log("\"Screenshot\""); +// public static void takeScreenshot(WebDriver driver) { +// // Known issue: ChromeDriver2 take screenshot is not full page +// // (https://code.google.com/p/chromedriver/issues/detail?id=294) +// File screenshot = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); +// DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss"); +// String screenshotsDirictory = ProjectConfiguration.getProperty("screenshots.directory.location") + "/screenshots"; +// new File(screenshotsDirictory).mkdirs(); +// String screenshotFilename = dateFormat.format(new Date()) + ".png"; +// try { +// FileUtils.copyFile(screenshot, new File(screenshotsDirictory + "/" + screenshotFilename)); +// } catch (IOException e) { +// e.printStackTrace(); +// } +// Reporter.log("\"Screenshot\""); +// } + + @Attachment(value = "Page screenshot", type = "image/png") + public static byte[] takeScreenshot(WebDriver driver) { + return ((TakesScreenshot) driver).getScreenshotAs(OutputType.BYTES); } } From 1408db06dff752d1e86d5240196162b157b9b96f Mon Sep 17 00:00:00 2001 From: faleev Date: Fri, 31 Oct 2014 15:00:24 +0200 Subject: [PATCH 3/3] Adding aspectj as a dependency. --- pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pom.xml b/pom.xml index eb38ec8..adb8375 100644 --- a/pom.xml +++ b/pom.xml @@ -82,6 +82,11 @@ + + org.aspectj + aspectjweaver + 1.7.4 +