Thanks - this does look like a good approach. The table's layout doesn't
change, it just reloads to update the data within the table with the
entries that were just made in the popup window. It's a really annoying
UI, especially when you have test cases that require changing a dozen
rows and therefore opening the popup a dozen times.. hence why I'm quite
eager to get Watir doing it instead.
However, each_with_index appears to be an undefined method for ie.table
objects. I can iterate on .each just fine, but .each_with_index is
undefined. (.rows is undefined as well; .each works fine if I leave it
out)
I'm wondering if maybe there's a way to store the indices of the buttons
it's going to click on within the array, rather than the rows
themselves. I tried buttons_to_click row[5].link(:index,1), but that
doesn't work.
Thanks,
Ian
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Ethan Jewett
Sent: Saturday, May 05, 2007 6:55 PM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] Using an ie.table.each do |row| loop when
thepage in the ie window refreshes itself
Ian,
Reloading probably invalidates the table object, resulting in your
Access denied error when ruby goes back for the next row in the
table.
Suggestion: Assuming that submitting and reloading doesn't affect the
table layout, use rows.each_with_index to build an array of indices of
relevant rows. Then cycle through the array clicking and submitting.
For instance (untested, unfortunately):
rows_to_click = Array.new
ie.table(:index, 29).rows.each_with_index do |row, i|
rows_to_click i if (row[1].text =~ /#{journals}/) != nil
end
rows_to_click.each do |i|
[Do the clicking and such for row i here.]
end
This could be made substantially prettier, but hopefully it gets the job
done.
Ethan
On 5/4/07, Ian Webb [EMAIL PROTECTED] wrote:
Here's the code snippet that's giving me problems:
ie.table(:index,29).each do |row|
if (row[1].text =~ /#{journals}/) != nil then #If there is a match
for that regex
row[5].link(:index,1).click # this makes the popup window appear
cw = Watir::IE.attach(:title,'Popup Window') # attach to the
popup
window
doRolesPopup(cw) # fill out and submit the form
end
end
doRolesPopup fills out a form in the cw page, then clicks submit. The
submit button submits the form, then closes the cw window and reloads
the ie window. This reload of the page referenced by the ie object
appears to break the row object, since I get the following error:
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2461:in `invoke': unknown
property or method `rows' (WIN32OLERuntimeError)
HRESULT error code:0x80070005
Access is denied. from
c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2461:in `row'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2404:in `each'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2404:in `upto'
from c:/ruby/lib/ruby/site_ruby/1.8/watir.rb:2404:in `each'
from assignroles.rb:51
from c:/ruby/lib/ruby/1.8/csv.rb:532:in `parse'
from c:/ruby/lib/ruby/1.8/csv.rb:560:in `each'
from c:/ruby/lib/ruby/1.8/csv.rb:531:in `parse'
from assignroles.rb:35
Is there any way to keep this simple .each loop, or do I need to work
around it?
Thanks,
Ian
___
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
___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general