I assume you say that this line fails:
assert($browser.text_field(:name, 'Name').exists?)
in test_FileCompanyInfo

Tricky...  Are there other def test_ in the class?
My immediate hunch is that tests run alphabetically and not sequentially if
you have more than one. could be that the test runs before you get to the
page and assert fails.

What happens if you just run the class TC_ with only this one test_ .
Set up manually and just run the class structure with that one test

Does this work when you are on the page?

class TC_myTests < Test::Unit::TestCase
def setup
 #init $browser here
end
def test_FileCompanyInfo
 assert($browser.text_field(:name, 'Name').exists?)
end
end



On 7/18/07, Lee <[EMAIL PROTECTED]> wrote:

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

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

Reply via email to