Ruby - Cucumber report a error when embed screenshot to html report

1,289 views
Skip to first unread message

Andy Zhang

unread,
Oct 22, 2013, 11:28:55 PM10/22/13
to cu...@googlegroups.com
I have this code to format cucumber output

#cucumber.yml
--format html --out reports/cucumber.html

And I have this code to embed one screenshot to my html report.
#hooks.rb After
@browser.screenshot.save("reports/screenshots/FAILED_#{scenario.__id__}.png")
embed
("screenshots/FAILED_#{scenario.__id__}.png",'image/png','Scenario_Failed_Screenshot')

But when my scenario failed, I get this message :

No such file or directory - screenshots/FAILED_78242760.png (Error::ENOENT)

Actually, the png file exists, and when I browser the html report, I can see the screenshot.

So I double this is a cucumber bug, embed function receive a string parameter, but it parse the string to a file path and check it exists, because the file is in subdirectory, so it can't see the file, but the html report can see the png file.

Anyone has an idea? Thanks!

Matt Wynne

unread,
Oct 24, 2013, 6:07:31 PM10/24/13
to cu...@googlegroups.com
If you think that's the case, try wrapping the path in File.expand_path(..) and see if that helps.


Anyone has an idea? Thanks!


--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Andy Zhang

unread,
Oct 28, 2013, 10:48:04 PM10/28/13
to cu...@googlegroups.com
Thanks Matt,

I follow your suggestion, use this code

    #cucumber.yml
    --format html --out reports/cucumber.html

  #hooks.rb After
  @browser.screenshot.save("reports/screenshots/FAILED_#{scenario.__id__}.png")

  embed
(File.expand_path("reports/screenshots/FAILED_#{scenario.__id__}.png"),'image/png','Scenario_Failed_Screenshot')

It works well, cucumber don't complain, and the screenshot displays correctly in the html report.

But it still has one problem, when I copy the reports directory to another place, or transfer it to my co-worker, the screenshot can't display correctly in the html report, because the HTML a element uses the absolute path of the screenshot.

So how can I fix this problem, and I still don't know why the cucumber embed file need check the screenshot path existence.

Thanks.

在 2013年10月25日星期五UTC+8上午6时07分31秒,Matt Wynne写道:

Matt Wynne

unread,
Oct 30, 2013, 4:28:22 AM10/30/13
to cu...@googlegroups.com
Hi Andy,

Please see rule 2 at the bottom of this email.

On 29 Oct 2013, at 02:48, Andy Zhang <andy...@gmail.com> wrote:

Thanks Matt,

I follow your suggestion, use this code

    #cucumber.yml
    --format html --out reports/cucumber.html

  #hooks.rb After
  @browser.screenshot.save("reports/screenshots/FAILED_#{scenario.__id__}.png")
  embed
(File.expand_path("reports/screenshots/FAILED_#{scenario.__id__}.png"),'image/png','Scenario_Failed_Screenshot')

It works well, cucumber don't complain, and the screenshot displays correctly in the html report.

But it still has one problem, when I copy the reports directory to another place, or transfer it to my co-worker, the screenshot can't display correctly in the html report, because the HTML a element uses the absolute path of the screenshot.

So how can I fix this problem, and I still don't know why the cucumber embed file need check the screenshot path existence.

Thanks.

That sounds like a bug in the HTML formatter. Could you try to send us a pull request?
Reply all
Reply to author
Forward
0 new messages