Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-11 Thread Charley Baker

 There's no flag in watir to swallow all exceptions, that's rather
dangerous behavior and not recommended. You could wrap methods with
begin/rescue blocks and print out the exceptions as they occur - follow
Zeljko's example above and the more specific the exceptions you catch the
better.

 I'd agree, it's not slick or pretty but it's the nature of the way test
unit is designed and my understanding of how these specific tests are coded
and the requirements. I reserve the right to be wrong on both accounts. :)
The way test unit and assertions work is more on a unit => single assertion
aspect vs grouping multiple assertion points(test cases) into one larger
grouping.

 For better or worse, I've ignored the issue to some extent as the
assertion points fold up into a larger test case, which I'm assuming passes
if all individual test points pass, and dump out of the test case with a
message on any individual assertion instead of bending it all around to a
functional pass through with multiple assertions that are all independent. I
added the ability track assertions in the test unit reports we're running
just to identify the running assertions. Otherwise, I'm basically using test
unit as is with it's limitations for true functional test scenarios.

-c

On 4/11/07, Vamsee Krishna M <[EMAIL PROTECTED]> wrote:


I think what he meant was he wants to execute each and every statement
without considering whether the previous statement was failed.

So the solution would be like putting try rescue catch block around around
each line and code won't look professional.

Is there any flag in watir that can be used to suppress all the exceptions
?
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-11 Thread Vamsee Krishna M
I think what he meant was he wants to execute each and every statement without 
considering whether the previous statement was failed. 

So the solution would be like putting try rescue catch block around around each 
line and code won't look professional.  

Is there any flag in watir that can be used to suppress all the exceptions ?
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-11 Thread Željko Filipin

On 4/11/07, watir-user watir-user <[EMAIL PROTECTED]> wrote:


Is there any other way which executes all the steps defined in the method
even any of the step fails and also should show the message why it has
failed?




Of course. Read "Exceptions, Catch, and Throw" chapter from "Programming
Ruby" (http://phrogz.net/ProgrammingRuby/tut_exceptions.html).

This is sample code.

begin
 raise
rescue
 puts $!
end

Zeljko
--
ZeljkoFilipin.com
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-11 Thread watir-user watir-user
Hi Charley and Paul,

If I use rescue true in the method, i wont be getting any error all the methods 
will execute. But, the method which has error does not shows what actual error 
it has.

Here is the code which i executed 

def test_yahooSite
test_site = 'http://www.mail.yahoo.com'
$ie = IE.new
$ie.goto(test_site)
assertTextfield
assertCheckbox #If this method fails it wont execute the next method
assertButton
end

def assertTextfield
assert($ie.text_field(:id,"username").exists?, "Username text field does not 
exist")
assert($ie.text_field(:id,"passwd").exists?, "Password text field does not 
exist")
end

def assertButton
  assert($ie.button(:value,"Sign In").exists?, "Sign In button does not 
exist")
end

def assertCheckbox
 assert_equal($ie.checkbox(:id, "persistent",2).isSet?, "Keep me signed in, 
 check box is not checked")
 rescue
 true
end

Is there any other way which executes all the steps defined in the method even 
any of the step fails and also should show the message why it has failed? 


That's what I get for answering emails before finishing my first cup of coffee. 
 :)

-c

 On 4/10/07, Paul  Carvalho < [EMAIL PROTECTED]> wrote: You're  repeating 
yourself, Charley. ;-)  This new assertions.rb covers one aspect of  what Watir 
User asked but not the other: "Its not only related to assertions ..  ".  
That's why I described a general Ruby construct for recovering from methods  
regardless of what Watir version you're using. 

Cheers.  Paul C. 


 On 10/04/07, Charley  Baker <  [EMAIL PROTECTED]> wrote: You  can also pull 
the assertions file and use it with Watir 1.4.1. 
https://svn.openqa.org/svn/watir/trunk/watir/watir/assertions.rbDownload 
this file, put it in your watir/watir directory and use it the  same way I 
mentioned in my previous mail.  

-Charley





   
-
 Check out what you're missing if you're not on Yahoo! Messenger 

yahoopage.rb
Description: 2132032765-yahoopage.rb


yahoorescue.rb
Description: 43341326-yahoorescue.rb
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread Charley Baker

That's what I get for answering emails before finishing my first cup of
coffee. :)

-c

On 4/10/07, Paul Carvalho <[EMAIL PROTECTED]> wrote:


You're repeating yourself, Charley. ;-)  This new assertions.rb covers one
aspect of what Watir User asked but not the other: "Its not only related to
assertions .. ".  That's why I described a general Ruby construct for
recovering from methods regardless of what Watir version you're using.

Cheers.  Paul C.


On 10/04/07, Charley Baker <[EMAIL PROTECTED]> wrote:
>
> You can also pull the assertions file and use it with Watir 1.4.1. 
https://svn.openqa.org/svn/watir/trunk/watir/watir/assertions.rb
>   Download this file, put it in your watir/watir directory and use it
> the same way I mentioned in my previous mail.
>
> -Charley
>


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread Paul Carvalho

You're repeating yourself, Charley. ;-)  This new assertions.rb covers one
aspect of what Watir User asked but not the other: "Its not only related to
assertions .. ".  That's why I described a general Ruby construct for
recovering from methods regardless of what Watir version you're using.

Cheers.  Paul C.


On 10/04/07, Charley Baker <[EMAIL PROTECTED]> wrote:


You can also pull the assertions file and use it with Watir 1.4.1.
https://svn.openqa.org/svn/watir/trunk/watir/watir/assertions.rb  Download
this file, put it in your watir/watir directory and use it the same way I
mentioned in my previous mail.

-Charley

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread Charley Baker

You can also pull the assertions file and use it with Watir 1.4.1.
https://svn.openqa.org/svn/watir/trunk/watir/watir/assertions.rb  Download
this file, put it in your watir/watir directory and use it the same way I
mentioned in my previous mail.

-Charley


On 4/10/07, Paul Carvalho <[EMAIL PROTECTED]> wrote:


I suppose you could always wrap a "rescue true" around each of your
assertions.  There are different ways of doing this.  This is just off the
top of my head but I'm pretty sure it works because I've done something
similar in the past.

One way would be:

def assertButton
   assert($ie.button(:caption, "Click Me").enabled?)  rescue true
end


If you have other commands that are likely to fail (e.g. a navigate link
command when the link isn't there), then you could wrap the rescue for the
whole method like this:

def assertButton
   assert($ie.button(:caption, "Click Me").enabled?)
rescue
   true
end

Where the "rescue" and "true" are the last lines before the "end" of the
method.  This will exit the method nicely and allow you to go to the next
method.  There are a lot of neat things you can do with a container like
this at the end of a test method.  If you want more information about
recovering from methods like this you should check out the "Programming
Ruby" book, second edition.

Hope this helps.  Paul C.


On 10/04/07, watir-user wrote:
>
>
> Hi Charley,
>
> Can you tell me how to overcome the same in Watir 1.4.1. Its not only
> related to assertions, the problem i am facing is if the method which i am
> calling if does not execute for some reason the  next step of the code does
> not executes in the called method. So, is there any other way to over come
> this problem in Watir 1.4.1?
>
> Any suggestions  most welcome
>
> Thanks,
>


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread Paul Carvalho

I suppose you could always wrap a "rescue true" around each of your
assertions.  There are different ways of doing this.  This is just off the
top of my head but I'm pretty sure it works because I've done something
similar in the past.

One way would be:

def assertButton
  assert($ie.button(:caption, "Click Me").enabled?)  rescue true
end


If you have other commands that are likely to fail (e.g. a navigate link
command when the link isn't there), then you could wrap the rescue for the
whole method like this:

def assertButton
  assert($ie.button(:caption, "Click Me").enabled?)
rescue
  true
end

Where the "rescue" and "true" are the last lines before the "end" of the
method.  This will exit the method nicely and allow you to go to the next
method.  There are a lot of neat things you can do with a container like
this at the end of a test method.  If you want more information about
recovering from methods like this you should check out the "Programming
Ruby" book, second edition.

Hope this helps.  Paul C.


On 10/04/07, watir-user wrote:



Hi Charley,

Can you tell me how to overcome the same in Watir 1.4.1. Its not only
related to assertions, the problem i am facing is if the method which i am
calling if does not execute for some reason the  next step of the code does
not executes in the called method. So, is there any other way to over come
this problem in Watir 1.4.1?

Any suggestions  most welcome

Thanks,

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-10 Thread watir-user watir-user
 
Hi Charley,

Can you tell me how to overcome the same in Watir 1.4.1. Its not only related 
to assertions, the problem i am facing is if the method which i am calling if 
does not execute for some reason the  next step of the code does not executes 
in the called method. So, is there any other way to over come this problem in 
Watir 1.4.1?

Any suggestions  most welcome 

Thanks,


 Hi watir user, 

  You can use the assertions methods that Bret  wrote in watir/assertions.rb 
that's included Watir 1.5.1.1100 and later (if  you're using 1.4.1 you can pull 
that file from subversion and use it).  

To use the verify methods: 
require 'watir/assertions'

Change  your asserts to verify and assert_equal to verify_equal: 

def  assertButton
  verify($ie.button(:caption, "Click Me").enabled?)  
end

etc. 

def check_controls
   assertButton
 .
end

Verify methods will be counted as  assertions in the test unit run without 
exiting out of the calling method.  

-Charley

 On 4/9/07, watir-user  watir-user <[EMAIL PROTECTED]>  wrote: Hi,

Following  methods i want to call in another method

def  assertButton
assert($ie.button(:caption, "Click  Me").enabled?)
end

def assertLink
assert($ie.link(:text, "Click  Me").exists? 
end

def assertTextfield
assert($ie.text_field(:name,  "field1").exists?)
end

def  assertRbutton
assert($ie.radio(:value,"radio  button").isSet?
end

def  check_controls
assertButton
assertLink
assertTextfield
assertRbutton
end

The  problem i am facing here is, in check_controls method if assertLink method 
 fails, it wont executes the next step of code just it comes out of the method. 
 But what i wanted is even if assertLink method fails it should execute the  
remaining methods (or next step of code)i.e, assertTextfield and assertRbutton  

Please help me in this regard,

Thanks in Advance
Watir User
  
-
 Here's a new way to find what you're looking for - Yahoo! Answers  
___
Wtr-general  mailing list
Wtr-general@rubyforge.org 
http://rubyforge.org/mailman/listinfo/wtr-general



   
-
 Check out what you're missing if you're not on Yahoo! Messenger ___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-09 Thread Charley Baker

Hi watir user,

 You can use the assertions methods that Bret wrote in watir/assertions.rb
that's included Watir 1.5.1.1100 and later (if you're using 1.4.1 you can
pull that file from subversion and use it).

To use the verify methods:
require 'watir/assertions'

Change your asserts to verify and assert_equal to verify_equal:

def assertButton
 verify($ie.button(:caption, "Click Me").enabled?)
end

etc.

def check_controls
 assertButton
.
end

Verify methods will be counted as assertions in the test unit run without
exiting out of the calling method.

-Charley

On 4/9/07, watir-user watir-user <[EMAIL PROTECTED]> wrote:


Hi,

Following methods i want to call in another method

def assertButton
assert($ie.button(:caption, "Click Me").enabled?)
end

def assertLink
assert($ie.link(:text, "Click Me").exists?
end

def assertTextfield
assert($ie.text_field(:name, "field1").exists?)
end

def assertRbutton
assert($ie.radio(:value,"radio button").isSet?
end

def check_controls
assertButton
assertLink
assertTextfield
assertRbutton
end

The problem i am facing here is, in check_controls method if assertLink
method fails, it wont executes the next step of code just it comes out of
the method. But what i wanted is even if assertLink method fails it should
execute the remaining methods (or next step of code)i.e, assertTextfield and
assertRbutton

Please help me in this regard,

Thanks in Advance
Watir User

--
Here's a new way to find what you're looking for - Yahoo! 
Answers


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

[Wtr-general] How to run all the steps defined in a method even if any of step fails?

2007-04-09 Thread watir-user watir-user
Hi,

Following methods i want to call in another method

def assertButton
assert($ie.button(:caption, "Click Me").enabled?)
end

def assertLink
assert($ie.link(:text, "Click Me").exists?
end

def assertTextfield
assert($ie.text_field(:name, "field1").exists?)
end

def assertRbutton
assert($ie.radio(:value,"radio button").isSet?
end

def check_controls
assertButton
assertLink
assertTextfield
assertRbutton
end

The problem i am facing here is, in check_controls method if assertLink method 
fails, it wont executes the next step of code just it comes out of the method. 
But what i wanted is even if assertLink method fails it should execute the 
remaining methods (or next step of code)i.e, assertTextfield and assertRbutton

Please help me in this regard,

Thanks in Advance
Watir User


-
 Here’s a new way to find what you're looking for - Yahoo! Answers ___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general