[wtr-general] Re: Handle Failures in Watir

2010-02-04 Thread Tiffany Fodor
Hi!

If you know which elements are likely to be missing, you could add a
verification that the element exists, which would trigger a failure if
it's missing and then add a conditional to act on it.  A Test::Unit
example would be:

verify((ie.link(:text, 'My Link').exists?), message='My Link didn't
exist on the page.')
if ie.link(:text, 'My Link').exists?
  ie.link(:text, 'My Link').click
end

If there are many element that are likely to be missing, you may want
to consider adding some good exception handling.  There's a discussion
here:

http://wiki.openqa.org/display/WTR/How+to+wait+with+Watir

Hope this helps!

-Tiffany

On Feb 4, 9:55 am, tester86 sagar.am...@gmail.com wrote:
 Hi

 Question for the watir group. When I run my test sometimes it fails if
 it cannot find an element or input field. Is there a way that when
 this occurs it can log that failure and continue running the tests and
 not stop. Is there any Watir commands that I can put in place at
 points in my script to cope with failures?

 I am using the ruby logger to output all my result into a text file.

-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general


[wtr-general] Re: Handle Failures in Watir

2010-02-04 Thread orde
You could do it a couple of ways.

1. Use an if/else statement (as seen here - 
http://wiki.openqa.org/display/WTR/Example+Logging)

if condition=true
   # log pass
else
   # log fail
end

2. Use the Exception class:

Here's the basic syntax:

begin
  # do something
rescue
  # log the failure if it fails.
end

For more detailed info, I'd strongly suggest getting familiar with
http://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html
and/or http://www.ruby-doc.org/core/classes/Exception.html

orde

On Feb 4, 8:55 am, tester86 sagar.am...@gmail.com wrote:
 Hi

 Question for the watir group. When I run my test sometimes it fails if
 it cannot find an element or input field. Is there a way that when
 this occurs it can log that failure and continue running the tests and
 not stop. Is there any Watir commands that I can put in place at
 points in my script to cope with failures?

 I am using the ruby logger to output all my result into a text file.

-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general


[wtr-general] Re: Handle Failures in Watir

2010-02-04 Thread tester86
Hi

I have been using if/else statements in my scripts but I was just
wondering if there was other ways that I could handle exceptions.
Thanks for your help.

On Feb 4, 12:03 pm, orde ohil...@gmail.com wrote:
 You could do it a couple of ways.

 1. Use an if/else statement (as seen here 
 -http://wiki.openqa.org/display/WTR/Example+Logging)

 if condition=true
    # log pass
 else
    # log fail
 end

 2. Use the Exception class:

 Here's the basic syntax:

 begin
   # do something
 rescue
   # log the failure if it fails.
 end

 For more detailed info, I'd strongly suggest getting familiar 
 withhttp://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html
 and/orhttp://www.ruby-doc.org/core/classes/Exception.html

 orde

 On Feb 4, 8:55 am, tester86 sagar.am...@gmail.com wrote:



  Hi

  Question for the watir group. When I run my test sometimes it fails if
  it cannot find an element or input field. Is there a way that when
  this occurs it can log that failure and continue running the tests and
  not stop. Is there any Watir commands that I can put in place at
  points in my script to cope with failures?

  I am using the ruby logger to output all my result into a text file.

-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general


[wtr-general] Re: Handle Failures in Watir

2010-02-04 Thread AR
I'm able to use begin/rescue/end for 99% of cases.  Normally I'll
collect the error into an array for logging or an email report
afterward.  Using those conventions, the script never stops, and I
don't have to be glued to the console to find out when it breaks.

On Feb 4, 1:42 pm, tester86 sagar.am...@gmail.com wrote:
 Hi

 I have been using if/else statements in my scripts but I was just
 wondering if there was other ways that I could handle exceptions.
 Thanks for your help.

 On Feb 4, 12:03 pm, orde ohil...@gmail.com wrote:

  You could do it a couple of ways.

  1. Use an if/else statement (as seen here 
  -http://wiki.openqa.org/display/WTR/Example+Logging)

  if condition=true
     # log pass
  else
     # log fail
  end

  2. Use the Exception class:

  Here's the basic syntax:

  begin
    # do something
  rescue
    # log the failure if it fails.
  end

  For more detailed info, I'd strongly suggest getting familiar 
  withhttp://www.ruby-doc.org/docs/ProgrammingRuby/html/tut_exceptions.html
  and/orhttp://www.ruby-doc.org/core/classes/Exception.html

  orde

  On Feb 4, 8:55 am, tester86 sagar.am...@gmail.com wrote:

   Hi

   Question for the watir group. When I run my test sometimes it fails if
   it cannot find an element or input field. Is there a way that when
   this occurs it can log that failure and continue running the tests and
   not stop. Is there any Watir commands that I can put in place at
   points in my script to cope with failures?

   I am using the ruby logger to output all my result into a text file.

-- 
You received this message because you are subscribed to the Google Groups 
Watir General group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to 
watir-general+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general