cucumber-attic / cucumber-html

Cross platform HTML formatter for all implementations of Cucumber
Other
40 stars 49 forks source link

Images failing to embed in html report #23

Closed tristanmccarthy closed 11 years ago

tristanmccarthy commented 11 years ago

Since the 1.1.1 release, embedding of images does not seem to be working correctly.

I'm using the following code:

    @After
    public void embedScreenshot(Scenario scenario)
    {
        if(scenario.isFailed())
        {   
            byte[] screenshot = ((TakesScreenshot)browserSession.driver).getScreenshotAs(OutputType.BYTES);
            scenario.embed(screenshot, "image/png");
        }
    }

Having checked against a recently updated example (https://github.com/cucumber/cucumber-jvm/blob/master/examples/java-webbit-websockets-selenium/src/test/java/cucumber/examples/java/websockets/SharedDriver.java), it doesn't seem that the approach has changed in any way.

On test failure I am now left with an image in the report directory, but no reference to it in the HTML report itself.

This has worked in previous versions up to and including 1.0.14, with a screenshot from webdriver being embedded in the report on scenario failure.

AlanFoster commented 11 years ago

+1 - I've just noticed this too.

I'm willing to fix this.... Should contributions for fixing this be made to this repository to to the cucumber-jvm one?

AlanFoster commented 11 years ago

I've just poked around and found out it's dying because the report is currently spitting out this to report.js

    formatter.embedding("\u0027image/png\u0027,\u0027embedded0.png\u0027");

It's being encoded oddly and therefore calling the function embedding(mimeType, data) with the wrong arguments. It should be easy to fix - if I could find out where it's being generated from :)

anshulbajpai commented 11 years ago

I believe it is getting generated from one of these formatters present in https://github.com/cucumber/gherkin/tree/master/java/src/main/java/gherkin/formatter

tristanmccarthy commented 11 years ago

Issue no longer present in cucumber-jvm since version 1.1.2.