Extent Report is not fetching images on using relative path. | Selenium Forum
S
Snehil Posted on 28/05/2021

Hi,

 

I am using below piece of code for taking screenshot -

public void takeScreenShot(){

Date d=new Date();
String screenshotFile=d.toString().replace(":", "_").replace(" ", "_")+".png";

File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
String filePath ="Screenshots//"+screenshotFile;


try {
FileUtils.copyFile(srcFile, new File(filePath)); //Put Capture in folder "Screenshots" > *WORKING FINE*
} catch (IOException e) {
e.printStackTrace();
}

test.log(LogStatus.INFO,"Screenshot -> "+ test.addScreenCapture(filePath)); //fetch capture from folder "Screenshots" to Extent Report > *NOT WORKING*

}

 

 

Folder Structure > 

Project

    Src

    Screenshots

    Report

    

> I am using relative path, so that I can share reports in mail. I understand that I need to share (report+screenshot) folders while sending in mail.

> Right now, In my local when I run this code, I can see screenshot file being saved in .png format in folder : Screenshots, But Report is not fetching these screenshots.

 

Please help to assist. Many thanks 

 


A
Ashish Replied on 01/06/2021

addScreenCapture requires absolute path

You can refer this post

https://stackoverflow.com/questions/3204955/converting-relative-paths-to-absolute-paths


Related Posts