pretty_face icon indicating copy to clipboard operation
pretty_face copied to clipboard

Help to configure custom screenshot location for Pretty face report

Open melvinpradep opened this issue 10 years ago • 1 comments

I see the Screenshot location in HTML report always looks for src = \images - instead i want to change this to custom location within my project, can someone help me to achieve this ?

melvinpradep avatar Nov 05 '15 17:11 melvinpradep

Hi @melvinpradep , the images are placed inside that folder to ensure:

  1. the report is portable (you could zip it up and send it to a friend)
  2. only the content for that explicit test run is stored/shared/loaded

When you take a screenshot and call the embed command, 2 images are made. One image is stored in whatever location you give to save_screenshot, and the other is stored in the /images dir of the report. I usually delete the un-embeded screenshot file and ONLY keep the images which live in the report folder.

The report would become brittle if you moved the images outside the report directory, I do not recommend it. However, if you want to experiment start with the following code block in html.rb

      def embed_image(src, label)
        @report.current_scenario.image << src.split(separator).last
        @report.current_scenario.image_label << label
        @report.current_scenario.image_id << "img_#{@img_id}"
        @img_id += 1
        filename = "#{File.dirname(@path)}#{separator}images"
        FileUtils.cp src, filename
      end

azohra avatar Nov 28 '15 23:11 azohra