3

Screenshots are not getting uploaded in klov report :

Getting below warning :

[testng] Jul 05, 2018 12:34:29 PM com.aventstack.extentreports.mediastorage.HttpMediaManagerKlov storeMedia [testng] WARNING: Unable to upload file to server C:\V2AutoWK/temp//screenshots/HLT_01--Failed_AT-VerifyTitle--0507_123427_PM(IST).png

The file is getting saved in db but unable to upload in klov report.

Any help is appreciated!

Zac
  • 1,305
  • 3
  • 17
  • 28
Tanveer
  • 31
  • 4

2 Answers2

4

Check your File Path : C:\V2AutoWK/temp//screenshots/HLT_01--Failed_AT-VerifyTitle--0507_123427_PM(IST).png

Which seems incorrect slashes with combination of Forward and Backward slashes.

The effective way is, You can store image within your project folder by absolute path.

public void takeScreenShot(String SSName) throws Exception
    {
        File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
        BufferedImage img = ImageIO.read(screen);
        File filetest = Paths.get(".").toAbsolutePath().normalize().toFile();
        ImageIO.write(img, "png", new File(filetest + "\\Screenshots\\" + " - " + SSName + ".png"));
        testlog.info("Details of " + SSName, MediaEntityBuilder.createScreenCaptureFromPath(System.getProperty("user.dir") + "\\Screenshots\\"  + " - " + SSName + ".png").build());
    }

Screenshot is fetched by ExtentReport method. You can find similar for klov.

Ishita Shah
  • 3,955
  • 2
  • 27
  • 51
  • Hi Ishita, Thanks for your inputs, I tried with your code as well, still getting the same error. Jul 05, 2018 3:35:05 PM com.aventstack.extentreports.mediastorage.HttpMediaManagerKlov storeMedia WARNING: Unable to upload file to server C:\V2AutoWK\temp\screenshots\Error.png – Tanveer Jul 05 '18 at 10:06
  • Please share your trial code, To retrieve image in Report – Ishita Shah Jul 05 '18 at 10:07
  • scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); BufferedImage img = ImageIO.read(scrFile); File filetest = Paths.get(".").toAbsolutePath().normalize().toFile(); System.out.println("filetest returned is "+filetest); ImageIO.write(img, "png", new File(filetest + "\\temp\\screenshots\\Error.png")); test.log(Status.ERROR,"Details of " + shortTcName, MediaEntityBuilder.createScreenCaptureFromPath(System.getProperty("user.dir") + "\\temp\\screenshots\\Error.png").build()); – Tanveer Jul 05 '18 at 10:12
  • You have made mistake in your code, Keep separate ".png" extension on both last line – Ishita Shah Jul 05 '18 at 10:17
  • Just for your info..with my previous code and your above provided code , screenshot is being attached successfully in html report(normal extent report). – Tanveer Jul 05 '18 at 10:18
  • Hi Ishita, i really appreciate your prompt help and support. I tried as below by putting separate ".png" extension for both lines but still no success. --------------------- ImageIO.write(img, "png", new File(filetest + "\\temp\\screenshots\\Error"+".png")); test.log(Status.ERROR,"Details of " + shortTcName, MediaEntityBuilder.createScreenCaptureFromPath(System.getProperty("user.dir") + "\\temp\\screenshots\\Error"+".png").build()); --------------------- – Tanveer Jul 05 '18 at 10:26
  • Just for your update: With your code, Image is shown as small thumbnill in Klov (localhost:90). But when i click on it open a small 10x10 blank image. Note: Images are appearing correctly in extent HTML Report – Tanveer Jul 05 '18 at 10:43
  • @Tanveer If you think provided assistance has helped you to solve problem, Please accept answer. – Ishita Shah Jul 05 '18 at 10:51
  • Hi Ishita, There is already same issue is logged in Klov as bug and is Still in OPEN state: https://github.com/anshooarora/klov/issues/45 – Tanveer Jul 06 '18 at 05:22
  • @Tanveer a fix has been released, please try with the latest. 3.1.6-SNAPSHOT. See #45 you referenced. – Karthik Jul 28 '18 at 01:03
2

This is a bug reported here: https://github.com/anshooarora/klov/issues/45

Hope that will be fixed soon!

Update: a fix has already been released with 3.1.6-SNAPSHOT.

Karthik
  • 477
  • 7
  • 18
Neagu V
  • 470
  • 4
  • 16