I am writing some tests for a web application, and my initial code in one of 
the tests was something like this:

=begin
setup code and includes/requires
   watir
=end

=begin
other tests needed to get to this point
=end

def FileCompanyInfo
 if $browser.text_field(:name, 'Name').exists? then
   if $broswer.text_field(:name, 'Name').verify_contains("") then
     $browser.text_field(:name, 'Name').set(::CLIENTNAME)
     $browser.text_field(:name,'Addr1').set(::CLIENTADDR1)
=begin     
      Code to fill in rest of form
=end     
   end
 end
end

And this works beautifully.

So next step was to add in some assertions and actual make the tests useful.

The code then  becomes:

=begin
setup code and includes/requires
   watir, test/unit and test/unit/ui/console/testrunner
=end

class TC_myTests < Test::Unit::TestCase

=begin
other tests needed to get to this point
=end

def test_FileCompanyInfo
 assert($browser.text_field(:name, 'Name').exists?)
   if $broswer.text_field(:name, 'Name').verify_contains("") then
     $browser.text_field(:name, 'Name').set(::CLIENTNAME)
     $browser.text_field(:name,'Addr1').set(::CLIENTADDR1)
=begin     
      Code to fill in rest of form
=end
  end
end

end

And this doesn't work - the assertion fails.  I have a couple of other tests 
before this that work just fine, as those are testing the process of navigating 
to this page.  The assertions in those work are working as expected.  I've 
tried accessing these text boxes by name, by index and by aftertext, and when I 
have the class in place, it's as if the fields do not exist (even though I can 
open the source and see that it does indeed exist)

I am new to Ruby and watir, though I am familiar with several other languages.  
What would cause these text fields to become invisible when I add this class 
definition around the set of methods?  I've looked at the documentation and 
several examples, and as far as I can tell, it should work still.

If anyone could point out what I am missing or what I have done wrong, I'd 
greatly appreciate it as my project and learning have ground to a sudden 
standstill.

Message was edited by: friedbob
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to