I'm pretty new to watir and I'm loving it so far, but I'm struggling to get 
the 'assert' to work the way I need it to. When I use 'assert' in a 
'begin-rescue' block, a failure of the assertion never seems to trigger the 
rescue, and therefore I cannot log the error message to a file or grab a 
screenshot or anything else. It simply outputs the failure to the console 
and goes to the end of the block (it will hit the 'ensure' statement if I 
use one). I feel like this is a pretty simple issue, but I can't seem to 
get around it. Anyone able to guide me down the right path?
 
Here's my simple script:
 
require 'watir'
require 'test/unit'
$ie = Watir::Browser.new
$ie.goto 'http://google.com'
class TC_Sample < Test::Unit::TestCase
 def test_01
  begin
   assert($ie.text.include?("Watir"), 'Cannot locate the text "Watir"')
  rescue
   puts 'Rescued the assert'
  end
 end
end
 
And here's the output from it:
 
Run options:
# Running tests:
F
Finished tests in 0.009000s, 111.1111 tests/s, 111.1111 assertions/s.
  1) Failure:
test_01(TC_Sample) [test1.rb:10]:
Cannot locate the text "Watir"
1 tests, 1 assertions, 1 failures, 0 errors, 0 skips
 
Thanks in advance.

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

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to