Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-28 Thread Tiffany Fodor
Thanks for the suggestion!

I tried it and I'm pointing to the correct link, so I still don't know what my 
problem with this is.  Looking up objects using IRB did help me with a 
different issue I was working through, however!
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-28 Thread Paul Carvalho

If the code below is an actual snippet from your code then could the *order*
the tests be the problem?

Please remember that the _default_ order of execution is ascending alpha, so
the script would likely try to run the tests in the following order
regardless of how they are arranged in the script :
1. test_addAccounts
2. test_login

If the script hasn't logged in *before* you try to add the account, then you
will always get an error.

There are different ways of working around this issue.  You could try
changing the test method names or insert a command to override the order of
test execution.  Check the message archives for details - I didn't find
anything in the FAQ right now for it.

Let us know if that helps.  Cheers.  Paul C.


On 25/06/07, Tiffany Fodor [EMAIL PROTECTED] wrote:


Hi!

I'm creating a test harness that will first collect all of the data
necessary to run the test cases then then execute the test cases.

Here's the code that is calling the test cases:

class TestScript  Test::Unit::TestCase

def test_login
login($producerName, $producerPass)
end

def test_addAccounts
addAccounts($testAccounts)
end
end

The login test works just fine, but the addAccounts test returns the
following:

Watir::Exception::UnknownObjectException: Unable to locate object, using
text and Find Account

This happens no matter what link or field I try to touch.  The same
commands work in the login test.  I've tried using the attach method to
specify what window to use, but that hasn't helped either.


___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-28 Thread Tiffany Fodor
Paul,

Thank you, thank you, thank you

I had moved on, assuming there was something weird about the way the login was 
working.

This morning, I added a new test case that wasn't in alphabetical order and 
I've been beating my head against my desk trying to figure out why debug 
statements from my third test were showing up before my second test started.  
Now that I've appended a number to the test names to indicate the correct 
order, they work just fine.  Yippee!!!

Thanks again for your help!

-Tiffany
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-28 Thread hhwwpssp
 Now that I've appended a number to the test names to indicate the correct 
 order, they work just fine.

Maintaining the numbers to keep correct order can become a pain as
your test suite grows.  You can also make the tests run in the order
you defined them by subclassing Watir::TestCase instead of
Test::Unit::TestCase.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-27 Thread Sorin
Suppose your login method didn't work properly because it was referencing to 
assert method, 
which is located in the class Test::Unit::TestCase class.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-27 Thread Tiffany Fodor
Thanks for the suggestion, but I don't think that's my problem.

I've continued adding tests to the framework and I have the assert method in my 
other tests as well.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-27 Thread Chong
Have you tried the login and subsequent click in irb? If that does not work 
(and it shouldn't yet, for consistency), you might want to try a 
show_all_objects and a show_frames to make sure you're looking in the right 
spot, and have the right target name.

Chong
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-26 Thread Tiffany Fodor
*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. MMDD
$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


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-26 Thread Tiffany Fodor
After some tinkering, I think I've figured out my problem.  It seems the 
Test::Unit::TestCase functionality is expecting to open files and run them as 
test cases rather than calls to methods in other files.

I was hoping to get all the data I need from a spreadsheet once, with the 
harness code, and then pass it to various test case methods rather than getting 
the data from the spreadsheet in each test case.  I think I can work around 
this, though.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-26 Thread Bill Agee
I noticed the line:

$ie.text_field(:name, Find Account).click

Is in both the end of the login method and the beginning of the
clickLinks method.  Maybe that is throwing off the state that
clickLinks expects?

Also, maybe check to see if test_clickLinks is running before
test_login.  If I recall correctly the test_ methods are run in
ASCIIbetical order.  If that is the case, then try collapsing the two
test_ methods into one.


On 6/26/07, Tiffany Fodor [EMAIL PROTECTED] wrote:
 After some tinkering, I think I've figured out my problem.  It seems the 
 Test::Unit::TestCase functionality is expecting to open files and run them as 
 test cases rather than calls to methods in other files.

 I was hoping to get all the data I need from a spreadsheet once, with the 
 harness code, and then pass it to various test case methods rather than 
 getting the data from the spreadsheet in each test case.  I think I can work 
 around this, though.
 ___
 Wtr-general mailing list
 Wtr-general@rubyforge.org
 http://rubyforge.org/mailman/listinfo/wtr-general

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] UnknownObject Exception when running test cases

2007-06-25 Thread Bret Pettichord
Tiffany Fodor wrote:
 Am I missing something?  Any help would be appreciated!
   
You'll have to share more of your code with us for us to help.

Bret
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general