Extent Report | Selenium Forum
M
Posted on 03/02/2016
Hi Team,

I am using extent report. And when I use screen shot code , it is not generating screen shot in the specified location. Below is my code:
-----------------
<!-- Extent Reports -->
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.40.1</version>
</dependency>



------------------
package man.manu.test;

import java.sql.*;
import java.util.HashMap;
import java.util.Map;

import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

import com.relevantcodes.extentreports.ExtentReports;
import com.relevantcodes.extentreports.ExtentTest;
import com.relevantcodes.extentreports.LogStatus;

import junit.framework.Assert;



public class TempTest {
private static ExtentReports logger;
@Test
public void Firsttest() throws ClassNotFoundException, SQLException
{

logger = new ExtentReports("G:\\report.html", true);
ExtentTest test = logger.startTest("My First Test", "Sample description");

//--------------

System.setProperty("webdriver.ie.driver", "C:\\Users\\Admin\\Downloads\\IEDriverServer_x64_2.48.0\\IEDriverServer.exe");


WebDriver driver= new InternetExplorerDriver();
driver.get("http://yahoo.com");




//-----------------
test.log(LogStatus.INFO, "Manoj This step shows usage of log(logStatus, details)");

String title=driver.getTitle();
// Assert.assertTrue(title.contains("Yahoo"));
test.log(LogStatus.PASS, "Title Matching");

//String img = test.addScreenCapture("G:\\test.png");
//test.log(LogStatus.INFO, "Image", "Image example: " + img);

test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("G:\\test1.png"));
test.log(LogStatus.INFO, "Screencast below: " + test.addScreencast("G:\\test2.png"));

driver.quit();
// end test
logger.endTest(test);

// calling flush writes everything to the log file
logger.flush();


}
}

M
Replied on 03/02/2016

where are the screen shot kept?


M
Replied on 04/02/2016

I didn't kept any screen shot. I am expecting screen shot to be generated in run time. Below is the code i got from extent report website.

test.log(LogStatus.INFO, "Snapshot below: " + test.addScreenCapture("G:\\test1.png"));
test.log(LogStatus.INFO, "Screencast below: " + test.addScreencast("G:\\test2.png"));


M
Replied on 04/02/2016

first you have to capture a screen shot using selenium and java then add that screen shot to extent reports.


M
Replied on 06/02/2016

Ok Thanks.

Do we have any vedio session, if a test case fails code will capture image ?


M
Replied on 07/02/2016

watch module 13.