CALABASH - Renaming screenshot filenames without the iterator

风流意气都作罢 提交于 2019-12-13 07:17:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!