Did you ever get a handle on your problems?  I've got hints for 1 & 2, I 
think if you  search this forum for logging pass fails you may find some 
hints.

Item 1) You need it to navigate back to the source page after the assert. 
it may be as simple as $browser.back or $browser.navigate.back
$browser.a(:text, 'Activities').click
    assert $browser.title == "Activities Navigation Page"
    $browser.back
    $browser.a(:text, 'Voter Registration').click
    ....

Item 2) setup looks like a mess.  You are using ARGV which is a command 
line argument.  At the command prompt is would be something like:
>ruby myScriptName.rb chrome

I run my scripts using textpad for my IDE and not the command line.

It looks like setup has a few other problems as well.

Here's my def for a browser launch

def Method_OpenBrowser(ie,sURL,sBrowserType) 
  puts ' * Method_OpenBrowser' 
  puts ' - Browser type: ' + sBrowserType.to_s 
  puts ' - URL: ' + sURL.to_s
  iFail=0
  case sBrowserType 
    when 'firefox' 
      ie = Watir::Browser.new(:firefox) 
      ie.window.maximize()
    when 'chrome' 
      ie = Watir::Browser.new(:chrome, :switches => %w[ --test-type ])
      #ie = Watir::Browser.new(:chrome)
      ie.window.maximize()
      sleep 4
    when 'ie' 
      ie = Watir::Browser.new(:internet_explorer) 
      ie.window.maximize()
    else 
      puts ' - FAIL. Browser type not found [ '+sBrowserType+' ]' 
      puts ' - Valid browser types: firefox, chrome, ie' 
      puts ' - ABORT. ' 
      30.times { puts ' ' }
      STDOUT.flush()
      exit
  end 
  ie.goto(sURL) 
  # This next command is a verification point.  If it fails it goes to the 
rescue, modify to what you can consistently verify against when the url 
opens.
  ie.link(:id,'ctl00_signoutButton_btnSignOutLink').wait_until_present  # 
Wait for the page to display, else lets just stop
  puts ' - PASS: URL Opened'
  puts ' - Return hwnd: '+ie.to_s 
  STDOUT.flush()
  return ie
rescue 
  puts ' - Rescue Login Failure. Abort!'
  iFail= -1
  puts ' - Return Fail = '+iFail.to_s 
  STDOUT.flush
  return iFail
end 



On Thursday, March 20, 2014 1:01:56 PM UTC-5, John Ringler wrote:
>
> 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