John Lolis wrote:
> Lets say we have the following
>
> Table
> .TR
> ..TD
> ..TD
> ...SPAN text=findme
> ..TD
> ...Text Input Field
>
> The only element in this entire section that I can identify uniquely is the
> span. The span happens to be located within a table. That table also contains
> the text input field (my real goal). So is there a way to find out what the
> table index is that contains a span? To explain it another way, here is some
> fake code.
>
> table_index =
> $ie.frame('frame1').span(:text,'findme').get_parent_table_index()
> $ie.frame('frame1').table(:index,table_index)[1][3].text_field(:index,
> 1).set('i did it!')
>
This problem comes up repeatedly both on this forum and in my daily use
of Watir. I believe that Watir needs to be extended to provide a solid,
intuitive way to do this kind of thing. This has been discussed some on
the wtr-development list.
First of all, i should say that this specific problem has a little-known
solution that is even in Watir 1.4.
span = $ie.frame('frame1').span(:text, 'findme').
table = Table.create_from_element(span, span)
table[1][3].text_field(:index, 1).set('i did it!')
However, i have run into similar situations, where i needed to get a
containing row instead of a table. There is not currently a
TableRow.create_from_element method, and it is not clear that this would
be the best API for this kind of thing.
I would appreciate comments on how intuitive you find the following
possible syntaxes. I also would appreciate hearing other suggestions.
table = $ie.frame('frame1').table(:containing, span)
table = span.parent.table(:index, 1)
It also seems that we need to support the case where you want to know
the containing element (say Div) of a particular class, so this is also
something to consider.
Some of these may be easier than others to implement, but right now i am
trying to figure out what would be an intuitive Watir-like syntax for
this kind of thing.
Bret
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general