lib/webdriver/screenshot.rb in aipim-rails-0.0.181 vs lib/webdriver/screenshot.rb in aipim-rails-0.0.182
- old
+ new
@@ -1,28 +1,31 @@
require 'selenium-webdriver'
%x[rm -fr aipim/screenshots/*]
Before do |scenario|
- @ScenarioTitle = scenario.title
- @ScenarioDescription = scenario.description
- @FeatureFile = scenario.file.to_s.split('/')
- @FeatureFile.delete_at(0)
- @FeatureFile = @FeatureFile.join('/')
- @FeatureName = scenario.feature.title
- @ScenarioTags = scenario.source_tag_names
+ if page.driver.browser.respond_to?(:manage)
+ @ScenarioTitle = scenario.title
+ @ScenarioDescription = scenario.description
+ @FeatureFile = scenario.file.to_s.split('/')
+ @FeatureFile.delete_at(0)
+ @FeatureFile = @FeatureFile.join('/')
+ @FeatureName = scenario.feature.title
+ @ScenarioTags = scenario.source_tag_names
- page.driver.browser.manage.window.maximize
- page.driver.browser.manage.window.resize_to(SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT)
+ page.driver.browser.manage.window.maximize
+ page.driver.browser.manage.window.resize_to(SCREENSHOT_WIDTH, SCREENSHOT_HEIGHT)
+ end
end
After do
- config = YAML.load_file("config/aipim.yml")
+ if page.driver.browser.respond_to?(:manage)
+ config = YAML.load_file("config/aipim.yml")
- if (@ScenarioTags.include?('@screenshot') && @ScenarioTags.include?('@javascript') && !page.driver.browser.nil? && config['screenshot'])
- path = "aipim/screenshots/#{@FeatureFile}"
- system("mkdir -p #{path}")
-
- sleep(1.0)
- page.driver.save_screenshot("#{path}/#{Time.now.to_i}.png")
+ if (@ScenarioTags.include?('@screenshot') && @ScenarioTags.include?('@javascript') && !page.driver.browser.nil? && config['screenshot'])
+ path = "aipim/screenshots/#{@FeatureFile}"
+ system("mkdir -p #{path}")
+ sleep(1.0)
+ page.driver.save_screenshot("#{path}/#{Time.now.to_i}.png")
+ end
end
end
\ No newline at end of file