Doubt regarding Exception handling in Watir

Hi all,

below is my code
def gotourl(url)
begin
$ie.goto(url)
rescue Watir::Exception::NavigationException => e
puts “navigation error”
printscreen(url)
end
end

1.in IE 8.0 version i get this error message when i navigate to invalid
URL “Internet Explorer cannot display the webpage”

my doubt is why rescue part is not executing for this error.

2.i want to know is it possible to use only “Watir::Exception” in my
rescue portion some thing this like this.

def gotourl(url)
begin
$ie.goto(url)
rescue Watir::Exception => e
puts “navigation error”
printscreen(url)
end
end

def clickbutton()
begin
$ie.button(:name,‘btnGs’).flash
rescue Watir::Exception => e # instead of
Watir::Exception::UnknownObjectException
puts “object not found error”
printscreen($ie.title)
end
end

  1. What is the best of Exception handling in watir?
    Please some body give me the best approach to do Exception handling
    in watir

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs