make sure only valid drivers take screenshots

This commit is contained in:
John Bintz 2012-07-25 14:34:49 -04:00
parent 00324b0538
commit aba28d6961
1 changed files with 11 additions and 8 deletions

View File

@ -7,16 +7,19 @@ module CukePack
end
def take_screenshot(name, options = {})
options = CukePack.screenshot_options.merge(options)
selenium = Capybara.current_session.driver.browser
selenium.manage.window.resize_to(options[:width], options[:height])
target = options[:directory]
target = File.join(target, Capybara.current_driver.to_s)
target = File.join(target, name + ".png")
if selenium.respond_to?(:manage)
options = CukePack.screenshot_options.merge(options)
FileUtils.mkdir_p File.dirname(target)
selenium.manage.window.resize_to(options[:width], options[:height])
selenium.save_screenshot(target)
target = options[:directory]
target = File.join(target, Capybara.current_driver.to_s)
target = File.join(target, name + ".png")
FileUtils.mkdir_p File.dirname(target)
selenium.save_screenshot(target)
end
end