Thanks for help. it worked But I used to "include Test::Unit::Assertions" in the Google class It's OK?
On Nov 19, 9:25 am, Dave McNulla <[email protected]> wrote: > 1. You had the assert in the Google cla > 2. You should let the class do the manipulation of the object > > See the changes that I made. Good luck, > > Dave > ------------------------ > require "rubygems" > require "firewatir" > require "test/unit" > class Google > def initialize > Watir::Browser.default = "firefox" > �...@ie = Watir::Browser.new > end > def simple_search(query) > @ie.goto("http://google.com") > @ie.text_field(:name, 'q').set query > @ie.button(:name, "btnG").click > sleep(2) > end > #added this function to the Google Class for evaluating whether > something is in the search results > def contains_text(result) > return @ie.contains_text(result) > end > #added this function to the Google Class to close the browser > def close > @ie.close > end > end > class TestGoogle < Test::Unit::TestCase > def setup > @site = Google.new > end > def test_watir_search > @site.simple_search("Watir") > #added this to the test, this is were you evaluate the results. the > search results are paired with the search string > assert(@site.contains_text("Watir, pronounced water, is an open- > source (BSD) family of Ruby libraries for automating web")) > end > def teardown > @site.close > end > end > > On Nov 18, 10:35 pm, Quang <[email protected]> wrote: > > > > > > > > > Hi all, > > This is google_search.rb: > > --------------------------------------------------------------------------- > > --------------------------------------------------------------------------- > > ---- > > require "rubygems" > > require "firewatir" > > require "test/unit" > > > class Google > > def initialize > > Watir::Browser.default = "firefox" > > �...@ie = Watir::Browser.new > > end > > > def simple_search(query) > > @ie.goto("http://google.com") > > @ie.text_field(:name, 'q').value = query > > @ie.button(:name, 'btnG').click > > sleep(2) > > assert(@ie.contains_text("Watir, pronounced water, is an open- > > source (BSD) family of Ruby libraries for automating web")) > > end > > end > > > class TestGoogle < Test::Unit::TestCase > > def setup > > @site = Google.new > > end > > > def test_watir_search > > @site.simple_search("Watir") > > end > > def teardown > > @site.close > > end > > end > > --------------------------------------------------------------------------- > > --------------------------------------------------------------------------- > > ---- > > > I have error: > > > NoMethodError: undefined method `assert' for #<Google:0x34eea50> > > D:\Working\FireMimo\FireMimo\test\google_test.rb:16:in `simple_search' > > D:\Working\FireMimo\FireMimo\test\google_test.rb:27:in > > `test_watir_search' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testcase.rb:452:in `__send__' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testcase.rb:452:in `run_test' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testcase.rb:320:in `run' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testsuite.rb:38:in `run' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testsuite.rb:37:in `each' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ > > testsuite.rb:37:in `run' > > C:/ruby/lib/ruby/gems/1.8/gems/test-unit-2.1.1/lib/test/unit/ui/ > > testrunnermediator.rb:48:in `run_suite' > > > I tried to replace "class Google" with "class Google < > > Test::Unit::TestCase" so it does not work > > > Please help, -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. [email protected] http://groups.google.com/group/watir-general [email protected]
