List Info

Thread: Re: How to run all the steps defined in a method even if any of step fails?




Re: How to run all the steps defined in a method even if any of step fails?
country flaguser name
India
2007-04-11 09:22:09
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 <gmail.com" href="mailto:tester.paulgmail.com"> tester.paulgmail.com> 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.&nbsp; Paul C.



On 10/04/07, Charley Baker <gmail.com" onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:charley.bakergmail.com" target="_blank"> charley.bakergmail.com> 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


Check out what you're missing if you're not on Yahoo! Messenger
  
  
Re: How to run all the steps defined in a method even if any of step fails?
user name
2007-04-11 09:55:17
On 4/11/07, watir-user watir-user < watir_useryahoo.co.in">watir_useryahoo.co.in> 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
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )