问题
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?
回答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")
回答2:
In lib/calabash-cucumber/failure_helpers.rb
the iterator is defined via @@screenshot_count ||= 0
then @@screenshot_count += 1
So I just overwrite that.
来源:https://stackoverflow.com/questions/28353303/calabash-renaming-screenshot-filenames-without-the-iterator