a very quick look suggesrs you need
if $ie.link(:text, $page.link_to_text ).exists?
in place of
if $ie.link(:text, page.link_to_text ).exists?
----- Original Message -----
From: Jeff Fry
To: wtr-general@rubyforge.org
Sent: Friday, June 15, 2007 6:43 PM
Subject: [Wtr-general] Breaking code into several classes and methods
Hi all,
I'm using my trusty pickaxe plus various code samples to try to take a script
of mine and break it up a bit into several classes and methods within
classes...and getting stuck.
When I run the code below, I get:
test_benchmark_page(TC_PerformanceBenchmark):
NoMethodError: undefined method `link_to_text' for #<Page:0x2e28b94>
performance_benchmark2.rb:56:in `benchmark'
performance_benchmark2.rb:54:in `times'
performance_benchmark2.rb:54:in `benchmark'
performance_benchmark2.rb:69:in `test_benchmark_page'
It complains about this line in particular:
if $ie.link(:text, page.link_to_text).exists?
But when I try it in irb it seems that page.link_to_text shouldn't be a
problem:
irb(main):040:0> $page = Page.new("c_eastwood",
"/view?id=%239202a8c04000641f800000000056de6", "Mystic River")
=> #<Page:0x2dafe24 @link_to_test="Mystic River",
@url="/view?id=%239202a8c0400641f8000000000056de6", @key="c_eastwood">
irb(main):041:0> $page.link_to_test
=> "Mystic River"
Here's my relevant code:
class TC_PerformanceBenchmark < Test::Unit::TestCase
...
def benchmark(page)
1.times do
$ie.goto($url_root + page.url)
if $ie.link(:text, page.link_to_text ).exists?
$results_array << $ie.down_load_time.to_s
p '$ie.down_load_time: '+$ie.down_load_time.to_s
else
$results_array << 'e'
p 'e'
end #if
end #do
end
def test_benchmark_page
login($url_root, $user, $pw)
$page = Page.new("c_eastwood",
"/view?id=%239202a8c04000641f8000000000056de6", "Mystic River")
benchmark($page)
end
end #class
class Page
def initialize (key, url, link_to_test)
@key = key
@url = url
@link_to_test = link_to_test
end
attr_reader :key
attr_reader :url
attr_reader :link_to_test
end
Any ideas?
Thanks,
Jeff
--
http://testingjeff.wordpress.com
------------------------------------------------------------------------------
_______________________________________________
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