Capture SS in log and email. | Selenium Forum
A
Abhishek Parida Posted on 30/07/2019

Hi Team,

I am able to capture ss in Extent Report Log in POM framework but when I sent the .html file for review the image is not found. How to overcome this issue?

 

Thanks,

Abhishek


A
Ashish Thakur Replied on 31/07/2019

In this case, you can zip the directory and send the content.


A
Abhishek Parida Replied on 07/08/2019

Meaning to I need to send the entire project everytime for reporting. I was send a zip file which had 2 folders, one with the .html file and other with ss. The code top  capture ss I used from your POM Module.

public void takeScreenShot(WebDriver webdriver, ExtentTest test) throws InterruptedException{
                Thread.sleep(2000);
                Date d=new Date();
                String screenshotFile=d.toString().replace(":", "_").replace(" ", "_")+".png";
                String filePath = System.getProperty("user.dir")+"\\ExtentReports\\screenshots\\"+screenshotFile;
                // store screenshot in that file
                File scrFile = ((TakesScreenshot)webdriver).getScreenshotAs(OutputType.FILE);
        }       
                try {
                        FileUtils.copyFile(scrFile, new File(filePath));
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                test.log(LogStatus.INFO,test.addScreenCapture(filePath));


A
Ashish Thakur Replied on 08/08/2019

No, we have code for zipping and mail. Discussed in Module 24. You'll get to know how you can zip the report contents and mail these