Skip to content

Enhanced rich hierarchical reporting for BDDfy #173

Open

Description

@dzharii

As an awesome pragmatic UI tester
I want to have the ability to include attachments into the BDDfy log
So that I will be able to view the screenshots and analyze the logs for Selenium WebDriver (or equivalent) tests.

Brief

  1. Hierarchical logging: the user can expand and collapse the Step section inside the HTML report file to view the detailed logging:
  2. Allow rich content inside the log file. Allow viewing images and open other attachments from the log file
  3. Idea: Markdown processing before generating the HTML report?

Conversation details:

http://www.mehdi-khalili.com/bddfy-v4

Hi Mehdi,

The Examples feature looks amazing. I am not using BDDfy for almost a year, but still recommend the framework for everyone who asks my advice on starting they first test automation project.

I think, BDDfy is perfect for non-UI tests: unit tests, database integration tests, web services tests… However, I found is difficult to adopt the framework for Selenium WebDriver.

The problem: It was difficult to control and extend the logging. My dream was to:

  1. Insert images and other attachments into the log
  2. Apply custom formatting for the log

Here is a “prototype” in Word ;)

Nobody had solved this issue with logs and reports for WebDriver tests yet. And everybody are inventing their own wheels ;)

Here is a “prototype” in Word ;)

Activity

  1. bondjasan commented on Sep 25, 2019

    @bondjasan

    Hi,
    I implement screen shot in reports in this way (If someone have better solution, please send)

    First, setup this in your tests (I use Nunit)
    [OneTimeSetUp]
    Configurator.StepExecutor = new ScreenShoter(path_to_image_folder);

    Important method:
    public override object Execute

    using OpenQA.Selenium;
    using System;
    using System.IO;
    using TestStack.BDDfy;

    namespace SimpleTests.Utils
    {
    public class ScreenShoter : StepExecutor
    {
    private string path = string.Empty;

        public ScreenShoter(string path) : base()
        {
            this.path = path;
        }
    
        public static string Take(string full_name)
        {
            try
            {
                Screenshot ss = ((ITakesScreenshot)WebDriver.driver).GetScreenshot();
                ss.SaveAsFile(full_name, ScreenshotImageFormat.Png);
            }
            finally
            {
    
            }
    
            return makeHtmlLink(full_name);
        }
    
        public static string makeHtmlLink(string full_name)
        {
            return string.Format("<img src=\"{0}\" height=150 width=150 align=left/>", full_name);
        }
    
        public override object Execute(Step step, object testObject)
        {
            try
            {
                return base.Execute(step, testObject);
            }
            catch(Exception ex)
            {
                var full_name = Path.Combine(this.path, step.Title) + ".png";                
                throw new Exception(ex.Message + " : " + Take(full_name));
            }
        }
    }
    

    }

    When tests is run, in exception message, image will appear inside step where exception is thrown.

    Regards.

  2. JeminJosephP commented on Nov 17, 2020

    @JeminJosephP

    @bondjasan

    How do you get the instance of WebDriver in ScreenShoter class?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions