Hi Tifanny,

Thanks for sharing this link.

One way to to get rid of the dirty console output is to completely redirect it 
to a log file.

But I just simply want to get rid of the following that gets printed on 
console, not the whole of the output:
I would like to redirect the following to a seperate log file, for debug 
purpose.
------------------------------------------------------------------------------------

1) Failure: 
 test_a_orderPlacement(BeboStickerbook) 
     [./Product.rb:14:in `AccessProductFromHomePage' 
      C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb: 
 42:in `test_ 
 a_orderPlacement']: 
 liProdStickerbookss does not exist on http://www.moo.com/. 
 <false> is not true. 
   2) Error: 
 test_an_edit(BeboStickerbook): 
 TypeError: can't convert Range into Integer 
     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb: 
 108:in `[]' 
     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb: 
 108:in `test_ 
 an_edit' 
 
  3) Error: 
 test_an_reorder(BeboStickerbook): 
 TypeError: can't convert Range into Integer 
     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb: 
 168:in `[]' 
     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb: 
 168:in `test_ 
 an_reorder' 
-------------------------------------------------------------------------------

Thanks,
Natasha

Tiffany Fodor <[EMAIL PROTECTED]> wrote: 
Hi Natasha!

Here's a discussion this topic that may help.

http://groups.google.com/group/watir-general/browse_thread/thread/a76fa88eaa260855/1af316cfbfc63fd3?lnk=gst&q=test%2Funit+assertions#1af316cfbfc63fd3

-Tiffany

On Nov 20, 11:02 am, Natasha  wrote:
> Hello All,
>
> I have tried using assertion in my code. Basically, I want to know if
> we could handle assertion failure effectively. Currently it gives an
> error and exits. Can I get redirect the failure and error
> notifications, towards the end of my output, to a log file, so that my
> console looks neat and clean.
>
> Also this is the first time I am using assertion alongwith exception
> handling. So is there a better way to write it.
>
> Following is the output that I got:
> -----------------------------------------------------------------------------------------
>
> C:\natasha\RubyScripts\FinalAutomatedTests>Stickerbook_bebo.rb 
> --www.moo.comtest test
>
> Loaded suite C:/natasha/RubyScripts/FinalAutomatedTests/
> Stickerbook_bebo
> Started
>  Using website :www.moo.comand user : test and password : test
> ------------------------------------------------------------------
> Test 1 : To test order placement for Bebo Stickerbooks
> Going to the MOO site:www.moo.com
>
> Product::AccessProductFromHomePage => liProdStickerbookss does not
> exist onhttp://www.moo.com/.
>  is not true.
>
> Finished in 1.703 seconds.
>
>   1) Failure:
> test_a_orderPlacement(BeboStickerbook)
>     [./Product.rb:14:in `AccessProductFromHomePage'
>      C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb:
> 42:in `test_
> a_orderPlacement']:
> liProdStickerbookss does not exist onhttp://www.moo.com/.
>  is not true.
>
>   2) Error:
> test_an_edit(BeboStickerbook):
> TypeError: can't convert Range into Integer
>     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb:
> 108:in `[]'
>     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb:
> 108:in `test_
> an_edit'
>
>   3) Error:
> test_an_reorder(BeboStickerbook):
> TypeError: can't convert Range into Integer
>     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb:
> 168:in `[]'
>     C:/natasha/RubyScripts/FinalAutomatedTests/Stickerbook_bebo.rb:
> 168:in `test_
> an_reorder'
>
> 3 tests, 1 assertions, 1 failures, 2 errors
>
> C:\natasha\RubyScripts\FinalAutomatedTests>
>
> -----------------------------------------------------------------------------------------
>
> Following is a piece of code that I have written, using assertion:
> -------------------------------------------------------------------------------------------------------------
> require 'watir'   # the controller
> require 'test/unit'
>
> module Product
>
> def AccessProductFromHomePage(product)
>
>         product_link_id =
> {"minicard"=>"liProdMinicards","businesscard"=>"liProdBusinesscards","holidaycard"=>"liProdGreetingcards","postcard"=>"liProdPostcards","stickerbook"=>"liProdSticker
> bookss","accessories"=>"liProdAccesories","all"=>"liProdSeeAll"}
>
>         linkid = product_link_id[product]
>
>         # assert
>         begin
>                 assert($ie.li(:id,linkid).link(:index,2).exists?,"#{linkid} 
> does not
> exist on " + $ie.url)
>                 puts 'Product:: AccessProductFromHomePage - Assertion passed'
>
>         rescue StandardError => ex
>                 print "\n\nProduct::AccessProductFromHomePage => " + ex + 
> "\n\n"
>                 raise
>
>         ensure
>                 $ie.close
>         end
>
>         # execute
>
>         $ie.li(:id,linkid).link(:index,2).click
>         puts "Product:: AccessProductFromHomePage - link for #{product} click
> on Home Page \n"
>         sleep 10
> end
>
> end # end of module
> -------------------------------------------------------------------------------------------------------------
>
> Thanks and regards,
> Natasha



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

Reply via email to