Extent Reports Version 4 | How to attach screenshots in Selenium WebDriver Java

Поділитися
Вставка
  • Опубліковано 1 лис 2024

КОМЕНТАРІ • 31

  • @sdfggsdfgsdfgsdfg
    @sdfggsdfgsdfgsdfg 6 місяців тому +1

    I never saw such a detailed video and I am able to recreate it without any issues . Thanks you so much!

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  5 місяців тому +1

      Glad you liked the video :)
      Please share the video with your friends to help us.

  • @psinha07
    @psinha07 3 роки тому +1

    Excellent way of explanation due to which I subscribed!

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  3 роки тому +2

      Glad you liked the video :)
      Please share the video with your friends to help us.

  • @jackvicky2173
    @jackvicky2173 3 роки тому +1

    Wow. I did subscribe to your channel. Thank you so much for the great video. the way you are explaining is so good.

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  3 роки тому +1

      Glad you liked the video :)
      Please share the video with your friends to help us.

  • @ahmadlove2650
    @ahmadlove2650 4 роки тому +1

    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 ?

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  4 роки тому

      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?

    • @ahmadlove2650
      @ahmadlove2650 4 роки тому +1

      ​@@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 .

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  4 роки тому +2

      @@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.

    • @ahmadlove2650
      @ahmadlove2650 4 роки тому

      @@LetsKodeItOfficial ah thank you it was very helpful

  • @abhishekthomas7799
    @abhishekthomas7799 4 роки тому +1

    Excellent ..it made me subscribe your channel!

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  4 роки тому +1

      Glad you liked the video :)
      Please share the video with your friends to help us.

  • @felipeluz1333
    @felipeluz1333 4 роки тому +2

    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);
    }
    }

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  4 роки тому +2

      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.

    • @felipeluz1333
      @felipeluz1333 4 роки тому +1

      @@LetsKodeItOfficial got it, thank you!

  • @kshipra4504
    @kshipra4504 2 роки тому +2

    Can you share the code?

  • @akhileshreddy7941
    @akhileshreddy7941 3 роки тому +1

    is Extent reports with screenshots will work if single @test is executed multiple times like in a loop?

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  3 роки тому

      Yes, it will work with TestNG DataProviders if that is what you are mentioning for running the same @Test multiple times.

  • @rachelr8150
    @rachelr8150 4 роки тому +1

    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;
    }

    • @LetsKodeItOfficial
      @LetsKodeItOfficial  4 роки тому +1

      I think I already sent you the code through email.
      Did it work for you?

    • @rachelr8150
      @rachelr8150 4 роки тому

      @@LetsKodeItOfficial yes its working.. Thank you ☺️

    • @manojpoojari7431
      @manojpoojari7431 2 роки тому

      @@rachelr8150 Hello , if you have that code can you please share???