The application I am testing uses intermediary pages and redirects for
messages. For example:
1. I'm on /mailings/new.tml, enter data and click SAVE.
2. For a couple seconds, I am directed to a "message page" (e.g.
/scripts/save_confirmation.tml) which informs me that "Your Mailing Has
Been Saved", and then automatically redirects me to:
3. /mailings/view_approval.tml
Now, watir tends to handle pages not yet having completed loaded
marvelously. It's one of many things I love about it...but it needs a
bit of instruction to handle these intermediary pages. In order to make
it through, we added:
while @ie.url != url
sleep 2
...but to my surprise that was still failing every 3rd or 5th iteration.
(Watir would tell me it couldn't find the link, but when I look at the
page the link is indeed there, suggesting to me that watir gave up
looking for the link before the page had finished loading.
I added an additional sleep 2 after the while loop exits (see wait_for,
below)...and instead of dying on the 5th iteration, it lasted 112
iterations. I could certainly give it an even longer sleep, but that's
just getting uglier and uglier, and I wonder if it'll still bomb out
eventually if the browser or server slows down further under load. Any
suggestions?
Is: while @ie.url != url
true once the url in question /finishes/ loading, or as soon as it
/starts/ loading? It seems to me that perhaps the latter is true, in
which case I am back to the old problem of my script giving up before
the page finishes loading.
I've pasted the whole script below. I could certainly pass on the html
of the page under test, but it's a long mess of conditional javascript,
so I'll wait for someone to tell me it'd be useful.
Thanks,
Jeff
class CREATE<Test::Unit::TestCase
def wait_for( url )
while @ie.url != url
sleep 2
end #while
sleep 2
end #def
def test_create_list
@machine = 'http://66.160.176.51'
@list = 'disc1'
@ie = Watir::IE.start(@machine)
@ie.typingspeed = 0
# Create i mailings
1.upto(5000) do |i|
@ie.link(:url, @machine+ "/?current_list="+ @list).click # goto
home page
@ie.button(:alt, "new mailing").click
@ie.text_field(:name, "moderate_.Title_").set("mailing-"+i.to_s)
@ie.text_field(:name, "moderate_.HdrSubject_").set("Subject
"+i.to_s)
@ie.text_field(:name, "moderate_.BodyText_").set("Text Body.")
@ie.button(:name, "save").click
puts "Created mailing "+i.to_s
wait_for( "[EMAIL PROTECTED]/mailings/view_approval.tml" )
end #do
@ie.close
end #def
end #class
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general