Watir will raise WatirNavigationException if it receives certain urls -
it does a regexp on the url looking for

shdoclc.dll ( if I remember correctly)

This is the exception that gets raised

irb(main):013:0> ie.goto('ggg.cddfdom')
Watir::Exception::NavigationException: Cannot find server or DNS Error
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1160:in
`check_for_http_error'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1141:in
`set_defaults'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1135:in `call'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1436:in
`run_error_checks'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in `each'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1435:in
`run_error_checks'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1419:in `wait'
        from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:1254:in `goto'
        from (irb):13
        from ♥:0
irb(main):014:0>

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:wtr-general-
[EMAIL PROTECTED] On Behalf Of Bret Pettichord
Sent: 26 October 2005 22:51
To: [email protected]
Subject: Re: [Wtr-general] getting the HTTP status


At 12:29 PM 10/26/2005, Sy Ali wrote:
>On 10/21/05, Pierre Garigue <[EMAIL PROTECTED]> wrote:
> > I because I 'rescue' everything, getting a 500 or 404 would just 
> > give
> me a fail. I would like to add info to the log that is failed and got
> this http status.
>
>I too am using the basic "rescue" technique, which doesn't really give 
>me a whole lot to work with.  I read through the technical docs[1] and 
>couldn't find anything more specific.  Perhaps this feature does not 
>exist?

The "rescue" technique was documented in old versions of the Watir 
documentation. It is a bad idea and had been removed from the version 
currently posted to the website.

Strictly speaking, this was never a Watir feature. Rather, rescue is a
Ruby 
feature, which doesn't really help with what you are doing here.

>I wonder what would happen if I turned on friendly error messages .. 
>then if rescue catches the error, could I scan the page or title to 
>determine the nature of the error?
>
>Here is my "go to" method, used with
>goto("http://example.org/foo/bar.html";) or goto(variable).  It's 
>different than yours because it notices succesfully-loaded, but 
>redirected pages:
>
>def goto(url)
>         begin
>                 puts "* going to " + url
>                 $ie.goto(url)
>         rescue
>                 puts ">>>ERROR"
>         else
>                 puts "   ok, destination loads"
>         end
>         if $ie.url() == url
>                 puts "   ok, I stayed at the destination url"
>         else
>                 puts "   warning: rewriting or redirection took
effect"
>         end
>end
>
>
>[1] http://wtr.rubyforge.org/rdoc/index.html

The fundamental problem is that an "error" at the http-protocol level
(like 
a 404) is not a Watir error. It won't raise an exception.

Why? Because from a user level (which is the level that Watir works at) 
there is no error. The browser shows a page -- maybe it is a 404 page.

You will have to add code to check to see if you got a page that was 
different from what you expected. Sometimes a 404 is what is supposed
to 
happen.

_____________________
  Bret Pettichord
  www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected] http://rubyforge.org/mailman/listinfo/wtr-
general


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to