*Sorry - here is my harness code (I've simplified it by removing the XLS 
interface code and addAccounts test so that it might be easier to drill down on 
the problem.  I have run this code to make sure the problem still happens.):*

require "win32ole" 
require "watir"   
require "test/unit"
require "watir/contrib/Xls" 
require "Login.rb"
require "ClickLinks.rb"
  

puts " "
puts "Please enter a unique identifier for your accounts"
puts "i.e. MMDDYYYY"
$accountID = gets.chomp
 

urls = Hash.new
urls["site1"] = "http://site1:7001/login.jsp";
urls["site2"] = "http://site2:27001/login.jsp";
 

puts "Please enter the server for the website under test."
puts "site1 (default) or site2"
test_site = "site1"
user_site = gets.downcase.chomp
if user_site != ""
        test_site = user_site
end     
if urls.include?(test_site) != true
        puts " "
        puts "You've entered an invalid server - please enter one of the 
following: site1 or site2."
        test_site = gets.downcase.chomp
end     
  
   

 $producerName = "testing"
 $producerPass = "password"
 puts " "
 puts "Please enter the Producer username you wish to use."
 puts "This producer must be assigned to the Approver you will use."
 puts "(default username/password = testing/password)"
 user_producer = gets.chomp
 if user_producer != ""
        $producerName = user_producer
        puts " "
        puts "Please enter the password for the producer."
        $producerPass = gets.chomp
        puts " "         
 end 

 puts " "
 puts "Please enter the Approver username you wish to use."
 puts "(default username/password = testApprove/password)"
 $approverName = "testApprove"
 $approverPass = "password"
 user_approver = gets.chomp
 if user_approver != ""
         $approverName = user_approver
         puts " "
         puts "Please enter the password for the Approver."
         $approverPass = gets.chomp
        puts " "
 end    


 $ie = Watir::IE.new
 $ie.goto(urls[test_site])
 
 class LoadTestScript < Test::Unit::TestCase
 
        def test_login
             login($producerName, $producerPass)
        end     
        
        def test_clickLinks
              clickLinks
        end
 end


*My login method looks like this and is saved in a separate file in the same 
directory as the harness as "Login.rb":*

require "win32ole" 
  require "watir" 
  
  def login(name, password)
        
        $ie.text_field(:name, "j_username").set($producerName)
        $ie.text_field(:name, "j_password").set($producerPass)
        $ie.link(:text, "Login").click
        
        assert($ie.link(:text, "Homepage").exists? == true)     
        $ie.text_field(:name, "Find Account").click     
  end   

*My clickLinks method looks like this and is saved in a separate file in the 
same directory as the harness as "ClickLinks.rb":*

require "win32ole" # the win32 module
require "watir"   # the watir controller

def clickLinks
        $ie.text_field(:name, "Find Account").click
        $ie.text_field(:name, "Find Building").set(password)
                
  end   


*I'm having the problem in the clickLinks test.  The "$ie.text_field(:name, 
"Find Account").click" command works in the login test, but in the clickLinks 
test, I get the following error:*

  1) Error:
test_clickLinks(LoadTestScript):
Watir::Exception::UnknownObjectException: Unable to locate object, using name 
and Find Account
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1192/./watir.rb:2425:in `assert_e
xists'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1192/./watir.rb:2654:in `enabled?
'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1192/./watir.rb:2429:in `assert_e
nabled'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1192/./watir.rb:2599:in `click!'
    c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.1.1192/./watir.rb:2585:in `click'
    ./ClickLinks.rb:18:in `clickLinks'
    C:/WatirScripts/Harness/WindHarness.rb:99:in `test_clickLinks'

2 tests, 1 assertions, 0 failures, 1 errors
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to