-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
110 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,7 +45,6 @@ build/ | |
.idea/ | ||
out/ | ||
*.iml | ||
reports/ | ||
report/ | ||
logs/ | ||
*.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.anhtester.reports; | ||
|
||
import com.anhtester.drivers.DriverManager; | ||
import io.qameta.allure.Attachment; | ||
import org.openqa.selenium.OutputType; | ||
import org.openqa.selenium.TakesScreenshot; | ||
|
||
public class AllureManager { | ||
|
||
private AllureManager() { | ||
} | ||
|
||
@Attachment(value = "Page screenshot", type = "image/png") | ||
public static byte[] saveScreenshotPNG() { | ||
return ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BYTES); | ||
} | ||
|
||
@Attachment(value = "{0}", type = "text/plain") | ||
public static String saveTextLog(String message) { | ||
return message; | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/anhtester/reports/ExtentReportManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.anhtester.reports; | ||
|
||
import com.anhtester.helpers.PropertiesHelper; | ||
import com.aventstack.extentreports.ExtentReports; | ||
import com.aventstack.extentreports.reporter.ExtentSparkReporter; | ||
|
||
public class ExtentReportManager { | ||
|
||
private static final ExtentReports extentReports = new ExtentReports(); | ||
|
||
public synchronized static ExtentReports getExtentReports() { | ||
ExtentSparkReporter reporter = new ExtentSparkReporter(PropertiesHelper.getValue("EXTENT_REPORT_PATH")); | ||
reporter.config().setReportName("Extent Report | " + PropertiesHelper.getValue("AUTHOR")); | ||
extentReports.attachReporter(reporter); | ||
// extentReports.setSystemInfo("Framework Name", "Test Automation Selenium Java"); | ||
// extentReports.setSystemInfo("Author", PropertiesHelper.getValue("AUTHOR")); | ||
return extentReports; | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
src/main/java/com/anhtester/reports/ExtentTestManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.anhtester.reports; | ||
|
||
import com.anhtester.drivers.DriverManager; | ||
import com.aventstack.extentreports.ExtentReports; | ||
import com.aventstack.extentreports.ExtentTest; | ||
import com.aventstack.extentreports.MediaEntityBuilder; | ||
import com.aventstack.extentreports.Status; | ||
import org.openqa.selenium.OutputType; | ||
import org.openqa.selenium.TakesScreenshot; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ExtentTestManager { | ||
static Map<Integer, ExtentTest> extentTestMap = new HashMap<>(); | ||
static ExtentReports extent = ExtentReportManager.getExtentReports(); | ||
|
||
public static ExtentTest getTest() { | ||
return extentTestMap.get((int) Thread.currentThread().getId()); | ||
} | ||
|
||
public static synchronized ExtentTest saveToReport(String testName, String desc) { | ||
ExtentTest test = extent.createTest(testName, desc); | ||
extentTestMap.put((int) Thread.currentThread().getId(), test); | ||
return test; | ||
} | ||
|
||
public static void addScreenShot(String message) { | ||
String base64Image = "data:image/png;base64," | ||
+ ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BASE64); | ||
|
||
getTest().log(Status.INFO, message, | ||
MediaEntityBuilder.createScreenCaptureFromBase64String(base64Image).build()); | ||
} | ||
|
||
public static void addScreenShot(Status status, String message) { | ||
String base64Image = "data:image/png;base64," | ||
+ ((TakesScreenshot) DriverManager.getDriver()).getScreenshotAs(OutputType.BASE64); | ||
|
||
getTest().log(status, message, | ||
MediaEntityBuilder.createScreenCaptureFromBase64String(base64Image).build()); | ||
} | ||
|
||
public static void logMessage(String message) { | ||
getTest().log(Status.INFO, message); | ||
} | ||
|
||
public static void logMessage(Status status, String message) { | ||
getTest().log(status, message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
browser = chrome | ||
email = admin@example.com | ||
password = 123456 | ||
timeout = 20 | ||
url = https://crm.anhtester.com/admin/authentication | ||
SCREENSHOT_PATH = reports/Screenshots/ | ||
VIDEO_RECORD_PATH = reports/VideoRecords/ | ||
HEADLESS = false | ||
VIDEO_RECORD = false | ||
SCREENSHOT_FAIL = true | ||
SCREENSHOT_PASS = false | ||
browser=chrome | ||
email=admin@example.com | ||
password=123456 | ||
timeout=20 | ||
url=https://crm.anhtester.com/admin/authentication | ||
SCREENSHOT_PATH=report/Screenshots/ | ||
VIDEO_RECORD_PATH=report/VideoRecords/ | ||
EXTENT_REPORT_PATH=report/ExtentReport/ExtentReport.html | ||
HEADLESS=false | ||
VIDEO_RECORD=false | ||
SCREENSHOT_FAIL=true | ||
SCREENSHOT_PASS=false | ||
AUTHOR=Anh Tester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters