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