[Wtr-general] Dissapearing text fields

2007-07-18 Thread Lee
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


Re: [Wtr-general] Dissapearing text fields

2007-07-18 Thread marekj

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

Re: [Wtr-general] Dissapearing text fields

2007-07-18 Thread Lee
I did some other searches, and found something that said that test runner 
executes them randomly, so I renamed my tests like it had suggested , 
test_000_name1  test_001_name2  etc to force the ordering, and it worked.  
There were multiple tests, but they had to be run in sequence.  Thanks, that 
did the trick.
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] Dissapearing text fields

2007-07-18 Thread marekj

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


I did some other searches, and found something that said that test runner
executes them randomly,



well, not 'randomly' but alphanumerically. test unit is built in a such a
way as not to introduce dependency between tests in a test case class. That
works for Unit tests but for our functional unit tests we need sequential
execution sometimes.
Please take a look at Watir::TestCase class. By default it sets up execution
of tests sequentially.

Maybe this should be added to FAQ on Watir site or a section on TestUnit.

So instead of doing this:
require 'test/unit'
class TC_myTests  Test::Unit::TestCase

do this:
require 'watir/testcase'
class TC_myTests  Watir::TestCase

and all your tests run sequentially.


--marekj

so I renamed my tests like it had suggested ,

test_000_name1  test_001_name2  etc to force the ordering, and it
worked.  There were multiple tests, but they had to be run in
sequence.  Thanks, that did the trick.
___
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