Hello , I liked your course and your explanation, I want to ask you about something, I am testing a web application, I have a list of charts on the dashboard I want to attach this list of charts to the reports and also take a screenshot for every charts ,Any ideas ?
Glad you found it helpful :) Please like and share the video and help us spread the word. You can take the screenshot of the charts when you navigate to the charts page and then attach them to the Extent Reports is that is needed. But what is the use-case to attach charts as it is to the Extent Report?
@@LetsKodeItOfficial well I need to attach this charts to extent report , for comparing if there's any changes in the future , so I want to attach all charts names+screenshots to my extent report .
@@ahmadlove2650 You will have to manually check them in Extent Report. You can do the same thing on the website directly. How will it help to attach the same thing in the Extent Report? To verify visual changes, you should use something like Applitools. If you want something open source, then try to explore Java Libraries which can do image comparison.
Nice video, just what I wanted! Thank you, you should definetly have more views. But unfortanelly, the screenshot wasn't attached to the report. The img has dysplay:none The screenshot is been saved in my IDE and I didn't get any issue when debugging. Here's my method: @AfterMethod public void afterMethod(ITestResult result) { String methodName = result.getMethod().getMethodName(); if (result.getStatus() == ITestResult.FAILURE) { String exceptionMessage = Arrays.toString((result.getThrowable().getStackTrace())); extentTest.fail("Exception Occured, click to see details:" + "" + exceptionMessage.replaceAll(",", "") + " "); String path = takeScreenshot(result.getMethod().getMethodName()); try { extentTest.fail("" + "Screenshot of failure" + "", MediaEntityBuilder.createScreenCaptureFromPath(path).build()); } catch (IOException e) { extentTest.fail("Test Failed, cannot attach screenshot"); } String logText = "Test Method " + methodName + " Failed"; Markup m = MarkupHelper.createLabel(logText, ExtentColor.RED); extentTest.log(Status.FAIL, m); } }
Glad you found it helpful :) Please like and share the video and help us spread the word. Please send an email at letskodeit@gmail.com and I will send you the code files.
I never saw such a detailed video and I am able to recreate it without any issues . Thanks you so much!
Glad you liked the video :)
Please share the video with your friends to help us.
Excellent way of explanation due to which I subscribed!
Glad you liked the video :)
Please share the video with your friends to help us.
Wow. I did subscribe to your channel. Thank you so much for the great video. the way you are explaining is so good.
Glad you liked the video :)
Please share the video with your friends to help us.
Hello , I liked your course and your explanation, I want to ask you about something, I am testing a web application, I have a list of charts on the dashboard I want to attach this list of charts to the reports and also take a screenshot for every charts ,Any ideas ?
Glad you found it helpful :)
Please like and share the video and help us spread the word.
You can take the screenshot of the charts when you navigate to the charts page and then attach them to the Extent Reports is that is needed. But what is the use-case to attach charts as it is to the Extent Report?
@@LetsKodeItOfficial well I need to attach this charts to extent report , for comparing if there's any changes in the future , so I want to attach all charts names+screenshots to my extent report .
@@ahmadlove2650 You will have to manually check them in Extent Report. You can do the same thing on the website directly. How will it help to attach the same thing in the Extent Report?
To verify visual changes, you should use something like Applitools.
If you want something open source, then try to explore Java Libraries which can do image comparison.
@@LetsKodeItOfficial ah thank you it was very helpful
Excellent ..it made me subscribe your channel!
Glad you liked the video :)
Please share the video with your friends to help us.
Nice video, just what I wanted! Thank you, you should definetly have more views.
But unfortanelly, the screenshot wasn't attached to the report. The img has dysplay:none
The screenshot is been saved in my IDE and I didn't get any issue when debugging.
Here's my method:
@AfterMethod
public void afterMethod(ITestResult result) {
String methodName = result.getMethod().getMethodName();
if (result.getStatus() == ITestResult.FAILURE) {
String exceptionMessage = Arrays.toString((result.getThrowable().getStackTrace()));
extentTest.fail("Exception Occured, click to see details:"
+ "" + exceptionMessage.replaceAll(",", "") + "
");
String path = takeScreenshot(result.getMethod().getMethodName());
try {
extentTest.fail("" + "Screenshot of failure" + "",
MediaEntityBuilder.createScreenCaptureFromPath(path).build());
} catch (IOException e) {
extentTest.fail("Test Failed, cannot attach screenshot");
}
String logText = "Test Method " + methodName + " Failed";
Markup m = MarkupHelper.createLabel(logText, ExtentColor.RED);
extentTest.log(Status.FAIL, m);
}
}
Glad you found it helpful :)
Please like and share the video and help us spread the word.
Please send an email at letskodeit@gmail.com and I will send you the code files.
@@LetsKodeItOfficial got it, thank you!
Can you share the code?
Sure, please email at letskodeit@gmail.com
is Extent reports with screenshots will work if single @test is executed multiple times like in a loop?
Yes, it will work with TestNG DataProviders if that is what you are mentioning for running the same @Test multiple times.
Thank you for a nice video. I watched all three videos and implemented it but screen shot is not attached with report. Kindly help me to attach the screenshot in extent report .
This is my code:
@AfterMethod
public void aftermethod(ITestResult result){
String methodname=result.getMethod().getMethodName();
if(result.getStatus()==ITestResult.FAILURE){
String exceptionmsg= Arrays.toString(result.getThrowable().getStackTrace());
extentTest.fail("Exception occurred, click to see the details:"+""+exceptionmsg.replaceAll(",","")+"
");
String path=takeScreenshot(result.getMethod().getMethodName());
try {
//extentTest.fail(""+"Screenshot of failure"+"", MediaEntityBuilder.createScreenCaptureFromPath(path).build());
extentTest.fail(""+"Screenshot of failure"+"", MediaEntityBuilder.createScreenCaptureFromPath(path).build());
}
catch (IOException E){
extentTest.fail("Test Failed, cannot attach screenshot");
}
String logText="Test Method "+methodname+" failed";
Markup m= MarkupHelper.createLabel(logText, ExtentColor.RED);
extentTest.log(Status.FAIL,m);
}
else if(result.getStatus()==ITestResult.SUCCESS){
String logText="Test Method "+methodname+" Passed";
Markup m= MarkupHelper.createLabel(logText, ExtentColor.GREEN);
extentTest.log(Status.PASS,m);
}
else if(result.getStatus()== ITestResult.SKIP){
String logText="Test Method "+methodname+" Skipped";
Markup m= MarkupHelper.createLabel(logText, ExtentColor.YELLOW);
extentTest.log(Status.SKIP,m);
}
}
public String takeScreenshot(String methodname){
String filename=getScreeenshot(methodname);
String directory=System.getProperty("user.dir")+"/Failed_screenshots/";
new File(directory).mkdirs();
String path=directory+filename;
try{
File screenshot=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot,new File(path));
System.out.println("**************************************************************");
System.out.println("Screenshot stored at: "+path);
System.out.println("**************************************************************");
}catch (Exception M){
M.printStackTrace();
}
return path;
}
public static String getScreeenshot(String methodname){
Date d=new Date();
String filename=methodname+"_"+d.toString().replace(":","_").replace(" ","_")+".png";
return filename;
}
I think I already sent you the code through email.
Did it work for you?
@@LetsKodeItOfficial yes its working.. Thank you ☺️
@@rachelr8150 Hello , if you have that code can you please share???