我正在使用葫芦对 iOS 本机应用程序进行测试。calabash 在场景失败时截取屏幕截图并将其命名为 screenshot_0 并将其保存在我的项目目录中。我想知道如何更改屏幕截图的路径以及如何更改文件名。
我使用了以下内容:
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
我在某处看到过page.driver.browser,simulator.save_screenshot ...并用模拟器替换了浏览器,但没有用...有没有办法改变ios sim保存模拟器的位置而不触及failure_helpers?