Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Added a method to add the screen shot image as base64 string in the report #384

Merged
merged 1 commit into from Mar 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -285,6 +285,18 @@ public String addScreenCapture(String imagePath) {

return screenCaptureHtml;
}

public String addBase64ScreenShot(String base64) {
String screenCaptureHtml = ScreenshotHtml.getBase64Source(base64);
ScreenCapture img = new ScreenCapture();
img.setSource(screenCaptureHtml);
img.setTestName(test.getName());
img.setTestId(test.getId());

test.setScreenCapture(img);

return screenCaptureHtml;
}

/**
* <p>
Expand Down
Expand Up @@ -27,6 +27,13 @@ public interface IExtentTestClass {

String addScreenCapture(String imgPath);

/**
* Adds the base64 screenshot into the report
* @param base64 The base64 string
* @return The image tag html with base64 image as src
*/
String addBase64ScreenShot(String base64);

String addScreencast(String screencastPath);

ExtentTest assignCategory(String... categories);
Expand Down
Expand Up @@ -12,4 +12,14 @@ public class ScreenshotHtml {
public static String getSource(String imgPath) {
return "<img class='report-img' data-featherlight='file:///" + imgPath + "' src='file:///" + imgPath + "' />";
}

/**
* Creates the image tag with base64 string as image source
* @param imgSrc Base64 String
* @return Image tag with base64 string as source
*/
public static String getBase64Source(String imgSrc) {
return "<img class='report-img' data-featherlight='<img src=\"" + imgSrc + "\" />' " +
"src='" + imgSrc + "' />";
}
}

Large diffs are not rendered by default.