I am trying to automate a simple test using WATIR. I am completely new at 
WATIR.
The test involves:
- browsing to a web site
- entering credentials to log in
- click on all the links in the navigation menu to ensure that each page 
loads properly.

To verify that each page loads properly, I basically look at the page title 
and make sure it is equal to the expected title.
I use "assert" for that.

My scripts works fine as long as each "assert" fails.

But there are several problems:

1) If any of the "asserts" fails, the script just stops. I'd like for the 
script to run all the way to the end. How do I do that?
2) I can not get the "browser_type" arg to work. My script only works with 
the default browser (Chrome). I would like the script to work for any 
browser. For example: "ruby test.rb ie" or "ruby test.rb firefox".
3) I have tried to figure out a way to first validate that link in the menu 
is present before doing the assertion but without success. For example, if 
I click on a borken link in the menu, it will open a page with a HTTP 404 
error code. The next test will fail because the page doesn't have the menu. 
I would need to go back to the previous page.
4) Is there a way to log any failure. I'd like to see a report that says: 
Page for 'Voter Registration' link failed. Actual title is 'Title XYZ'.

Thanks a lot. I'll do some more research do try to get all this to work.

------------------------------------------------------------------------------------------------------------------------------------------------------

require "test/unit"
require "watir-webdriver"


class TC_NavMenu < Test::Unit::TestCase


def setup 
    $browser ||= Watir::Browser.new :chrome if $browser.nil?
    $site = 'https://my_test_url'

    # Login Credentials for UAT
    $id = 'test'
    $pwd = 'password*123'

     if ARGV[0] == 'chrome'
       $type = 'chrome'
     if ARGV[0] == 'ie'
       $type = 'ie'   
     elseif ARGV[0] == 'ff'
       $type = 'firefox'
     elseif ARGV[0] == 'firefox'
       $type = 'firefox'
     end
    if $type == 'chrome'
      $browser = Watir::Browser.new :chrome
    elsif $type == 'firefox'
      $browser = Watir::Browser.new :ff
    elsif $type == 'ie'
      $browser = Watir::Browser.new :ie
end  
end
end


   
def teardown 
    $browser.close
end
  
def test_navigation
    # Login
    $browser.goto $site
    $browser.text_field(:name, 'identifier').set($id)
    $browser.text_field(:name, 'password').set($pwd)
    $browser.button(:value, 'Login').click

 
    # County Select
    $browser.select_list(:name, 'town').select_value('00017')
    $browser.button(:value, 'Change County').click

    # ---------------------------------------------------------------
    # Navigation : Activities > Voter Registration
    # ---------------------------------------------------------------
    $browser.a(:text, 'Activities').click
    assert $browser.title == "Activities Navigation Page"
  
      $browser.a(:text, 'Voter Registration').click
      assert $browser.title == "Voter Registration Navigation Page"
      $browser.a(:text, 'Add/Change Voter').click
      assert $browser.title == "Search - Voter Registration"
      $browser.a(:text, 'Voter With No DOB').click
      assert $browser.title == "Registration Application - New Voter 
Registration"
      $browser.a(:text, 'Voter Address Change Confirmation').click
      assert $browser.title == "Address Change Confirmation"
      $browser.a(:text, 'Voter Address Change Confirmation Export').click
      assert $browser.title == "Voter Address Change Confirmation Export"
      $browser.a(:text, 'MVC - Agency').click
      assert $browser.title == "MVC File - Agency"
      $browser.a(:text, 'MVC File Online Voter').click
      assert $browser.title == "MVC File - Online Voter"
      $browser.a(:text, 'Voters who have Verification / Postal 
Notice').click
      assert $browser.title == "Verification / Postal Notice Batch"
      $browser.a(:text, 'Verif. and Ack. Card Export').click
      assert $browser.title == "Verification and Acknowledgement Card 
Export"
      $browser.a(:text, 'MVC Manual Update').click
      assert $browser.title == "MVC File - Manual Update"
  end
end

-- 
-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to