How can I catch browser error in watir?
You need to look up Ruby error handling.
This is from rubylearning.com:
def raise_and_rescue
begin
puts ‘I am before the raise.’
raise ‘An error has occured.’
puts ‘I am after the raise.’
rescue
puts ‘I am rescued.’
end
puts ‘I am after the begin block.’
end
raise_and_rescue
To use this with watir’s errors, you just place your code within a
begin/rescue/end block, or you can use rescue within a method, like
this:
def this_is_a_method
puts “Main method”
raise “I am an error”
puts “I’m after the error”
rescue
puts “Rescued an error”
end