0

In Calabash you can take a screenshot and rename it to whatever you want and save it to any directory like so:

screenshot({:prefix => "some/directory", :name=>"some_name.png"})

However it will always save as some_name_0.png and the next one will be some_name_1.png.

Does anyone know how to rename the filename completely without the iterator?

YoDK
  • 447
  • 1
  • 4
  • 13

2 Answers2

1

You can also just pass text from your steps on what to save the screendump as. I have done this to easily set the prefix and name and only take the screendumps when I add "capture=true" to the start command.

def take_picture(prefix, name)
  if ENV["capture"] == 'true'
    screenshot(options={:prefix=>prefix, :name=>name})
  end
end

And from the steps I call it like this(this is example does not add special prefix:

take_picture("","SettingsMenu1")
Lasse
  • 1,153
  • 1
  • 10
  • 21
  • Thanks for your suggestion. Unfortunately this behaves the same way as described in the problem. It appears that ```@@screenshot_count``` needs to be manipulated to remove the appended screenshot count. – YoDK Feb 09 '15 at 20:53
  • Ah yes you are right. I did not read you question thoroughly enough. It was only the numbering you had an issue with. But what would you like to do in that case? Replace the existing picture or should the new picture not be saved, in case one picture with same name already exists? You could add a prefix for each feature/scenario and then you could ensure that you get only one image with each name. – Lasse Feb 10 '15 at 02:48
0

In lib/calabash-cucumber/failure_helpers.rb the iterator is defined via @@screenshot_count ||= 0 then @@screenshot_count += 1

So I just overwrite that.

YoDK
  • 447
  • 1
  • 4
  • 13