This is all fine if you don't care about "hard coding" your table indexes or
don't expect your page layout to change.
Here is how I did it without using hard coded indexes.
(Note: use unique data that will get you the table you want. If there are
multiple tables nested within an outer table you may have to use different data
to get to the nested table you want)
*EXAMPLE*: On my page, table #9 is nested within Table #8. So using the above
code I could do this:
t=ie.table(:index,8).table(:index,1)
However, If I want to access the nested table by a text value (or other just
substitute other object)
outer_table = @ie.tables.find {|t| t.text =~ /#{data}/i }
nested_table = outer_table.tables.find {|t| t.text =~ /#{data}/i } +<===
this can be repeated for multi-nesting+
r=nested_table.rows.find{|r| r.text =~ /#{data}/i }
Now I have the Row the Item I was looking for is in. I can now do what I want
with that row.
Hope this was helpful.
*EXAMPLE 2*:
Page has table #4 is nested within Table #5, Table #6, and Table#9.
Table #6 nests Table #7 and Table #8.
I want a cell in table #8. However, tables #5 and #6 both contain the
#{data} that I am looking for. So I will use #{unique} data to specify table #6
So using the above code I could do this:
t=ie.table(:index,4).table(:index,2).table(:index,2)
Heres how I would do it:
outer_table = @ie.tables.find {|t| t.text =~ /#{data}/i }
<== Table #4
nested_table = outer_table.tables.find {|t| t.text =~ /#{unique}/i } <==
Table #6
nested_table = nested_table.tables.find {|t| t.text =~ /#{data}/i } <==
Table #8
r=nested_table.rows.find{|r| r.text =~ /#{data}/i }
<== Row in Table #8 that has #{data}
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general