When I am sending the extent-report to other person screenshot is missing from the report and i have tried every ways zipped the report and send it but same issues was there. I have implemented in Cucumber framework by using hooks concept in that I have used robot class.So,please anyone can help me out.
Asked
Active
Viewed 81 times
0
-
It would be nice if you share the the code that you have written for setting up extent and taking screenshots. It might be possible that you are using a different folder for your screenshots and when you send the extent-report or try to open it on different machine, the path gets broken hence you don't see images. – Ayaz Aug 04 '20 at 09:52
-
hey @Ayaz - here is the code – Gunjan Attri Aug 07 '20 at 15:26
-
You might want to read through the [tour] and [ask] to get a better idea of how this site works, so that you can get the answer you are after. – SiKing Aug 07 '20 at 16:30
1 Answers
0
*package stepDefinitions;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
//import java.io.ByteArrayOutputStream;
import java.io.File;
//import java.util.Base64;
import java.awt.Rectangle;
import javax.imageio.ImageIO;
import com.cucumber.listener.Reporter;
import cucumber.api.Scenario;
import cucumber.api.java.After;
import cucumber.api.java.Before;
public class Hook
{
@Before(" @TC001")
public void setup() {
Reporter.assignAuthor("QA - Gunjan Attri");
System.out.println("open");
}
@After("@TC001")
public static void tearDown(Scenario scenario) {
if (scenario.isFailed()) {
try {
System.out.println("Test case which got failed is " + scenario.getName());
Robot awt_robot = new Robot();
BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
String Destination = "D:\\OFFICE\\Office Project\\office\\HermesCucumberBDD\\screenshots\\"+scenario.getName()+".png";
//ByteArrayOutputStream outStream = new ByteArrayOutputStream();
ImageIO.write(Entire_Screen, "PNG", new File(Destination));
//encodedData = Base64.encodeBase64(outStream.toByteArray());
Reporter.addScreenCaptureFromPath(Destination);
} catch (Exception e) {
e.printStackTrace();
}
} else {
try {
System.out.println("Test case which got passed is " + scenario.getName());
Robot awt_robot = new Robot();
BufferedImage Entire_Screen = awt_robot.createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
String Destination = "D:\\OFFICE\\Office Project\\office\\HermesCucumberBDD\\screenshots\\"+scenario.getName()+".png";
ImageIO.write(Entire_Screen, "PNG", new File(Destination));
Reporter.addScreenCaptureFromPath(Destination);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}*
-
This is not an answer. Please [edit](https://stackoverflow.com/posts/63243973/edit) your original question with this information. – SiKing Aug 07 '20 at 16:27