i am using calabash to do testing on a iOS native app. calabash takes a screenshot and names it screenshot_0 on scenario failure and saves it in my project directory. i want to know how i can change the path of the screenshot and how i can change the name of the file.
i used the following:
dir_path = "/Users/bmw/Desktop/Calabash/screenshots "
unless Dir.exist?(dir_path)
Dir.mkdir(dir_path,0777)
puts "=========Directory is created at #{dir_path}"
else
puts "=========Directory already exists at #{dir_path}"
end
#Run after each scenario
After do |scenario|
#Check, scenario is failed?
if(scenario.failed?)
time = Time.now.strftime('%Y_%m_%d_%Y_%H_%M_%S_')
name_of_scenario = time + scenario.name.gsub(/\s+/, "_").gsub("/","_")
puts "Name of snapshot is #{name_of_scenario}"
file_path = File.expand_path(dir_path)+'/'+name_of_scenario +'.png'
page.driver.simulator.save_screenshot file_path
puts "Snapshot is taken"
puts "#===========================================================#"
puts "Scenario:: #{scenario.name}"
puts "#===========================================================#"
end
end
i had seen page.driver.browser,simulator.save_screenshot somewhere... and replaced browser with simulator and that did not work... is there any way to change location where ios sim saves simulator without touching failure_helpers?