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

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



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

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to