I am trying to set up ability to take screen shots. I'm not concerned if they embed or are saved to a directory.
I have googled several suggestions, but none have worked.
Right now I am trying to use example from http://watirmelon.com/tag/cucumber/
I am using Ruby 1.9, Watir 4.0.2, and Cucumber 1.2.1
Windows 7 with IE 9
I have a hooks.rb file with the following
After do |scenario|
if scenario.failed?
Dir::mkdir('screenshots') if not File.directory?('screenshots')
screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
Browser::BROWSER.driver.save_screenshot(screenshot)
embed screenshot, 'image/png'
end
end
start of my ruby file is
require 'watir'
include Watir
ie = Watir::Browser.new
any suggestions to making this work?
Or if better suggestion to including other gems in my script and using something I am totally open. I just would like to get screenshots to work, specifically on failed features.
Thanks in advance
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
uninitialized constant Watir::Browser::BROWSER (NameError)
C:/Users/Darkhudson/Desktop/DEMO/watirDemo/workspace/features/support/hooks.rb:5:in `After'
3 Dir::mkdir('screenshots') if not File.directory?('screenshots')
4 screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
5 Browser::BROWSER.driver.save_screenshot(screenshot)
6 embed screenshot, 'image/png'
7 endYes,
The script finishes and when I check my html log, I see this after the failed feature.uninitialized constant Watir::Browser::BROWSER (NameError)C:/Users/Darkhudson/Desktop/DEMO/watirDemo/workspace/features/support/hooks.rb:5:in `After'3 Dir::mkdir('screenshots') if not File.directory?('screenshots') 4 screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png" 5 Browser::BROWSER.driver.save_screenshot(screenshot) 6 embed screenshot, 'image/png' 7 end
On Friday, November 9, 2012 7:22:47 PM UTC-8, Ryan Crossan wrote:I am trying to set up ability to take screen shots. I'm not concerned if they embed or are saved to a directory.
I have googled several suggestions, but none have worked.
Right now I am trying to use example from http://watirmelon.com/tag/cucumber/
I am using Ruby 1.9, Watir 4.0.2, and Cucumber 1.2.1
Windows 7 with IE 9
I have a hooks.rb file with the following
After do |scenario|
if scenario.failed?
Dir::mkdir('screenshots') if not File.directory?('screenshots')
screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png"
Browser::BROWSER.driver.save_screenshot(screenshot)
embed screenshot, 'image/png'
end
end
start of my ruby file is
require 'watir'
include Watir
ie = Watir::Browser.new
any suggestions to making this work?
Or if better suggestion to including other gems in my script and using something I am totally open. I just would like to get screenshots to work, specifically on failed features.
Thanks in advance
--
-- Rules --
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
Yes,
The script finishes and when I check my html log, I see this after the failed feature.uninitialized constant Watir::Browser::BROWSER (NameError)C:/Users/Darkhudson/Desktop/DEMO/watirDemo/workspace/features/support/hooks.rb:5:in `After'3 Dir::mkdir('screenshots') if not File.directory?('screenshots') 4 screenshot = "./screenshots/FAILED_#{scenario.name.gsub(' ','_').gsub(/[^0-9A-Za-z_]/, '')}.png" 5 Browser::BROWSER.driver.save_screenshot(screenshot) 6 embed screenshot, 'image/png' 7 end