Check out the latest version of Watir from HEAD.

Now you can do:

  ie.table().table().table().cell().image().click

Each item searches inside the previous item. This now works with any element type.

In your case, you probably want something like:

ie.table().table().table().cells.each {|c| c.text.strip if c.image(:src, xxx).exists?}

Bret

At 12:26 PM 9/1/2005, Warren Pollans wrote:
Thanks for the suggestion.  It works - but a little too well  :-)

It turns out that the page I'm checking has tables inside of tables
inside of tables ...

So this is returning the text in the highest level cell (including
those below it) that contains the image I specify although the actual
cell with the image is several layers down.  This is OK  before I was
matching ie.text to some expected text.

Now I'm curious.  Is there a way to keep track of where I am in the
hierarchy of tables so I know when I'm at the deepest level?  In your
example below, I guess I could save the text from each cell that
matches instead of returning one the first match - and then pick the
shortest string.  Is there a watir way?

On or about Fri, 19 Aug 2005 12:16:13 -0400
Shao Kang Tat <[EMAIL PROTECTED]> allegedly wrote:

> I'm doing something similar.  But I'm not dealing with images, rather
> links and texts, so I'd imagine the code would be similar to the one
> I"m using and would work:
>
>
> ie.tables.each do|t|  # since you don't have ID's, look at every table
>     for i in 1..t.row_count   # for every row in this table
>
>         # for every column in this row, look at its contents
>         t[i].each{|c| if c.image(:src, xxx).exists?  # if true, this
> is your cell
>                      return c.text.strip
>         }
>     end
> end
>
>
>
>
>
>
>
> On 8/19/05, Warren Pollans <[EMAIL PROTECTED]> wrote:
> > Hello again,
> >
> > Could some please point me to a way of finding text in a cell that
> > contains a specified image?  There are no ids available for the
> > table, row or cell :-( - and there are several tables on the page.
> > There is only one cell (at a time) that contains this particular
> > image - the text in the cell is displaying status that I'm trying
> > to capture.  This status msg can occur in one of four different
> > tables - depending on which form on the page is submitted - the
> > same image is used in all cases.
> >
> > I think I want to walk through the DOM looking for a td element
> > that has "img src=xxx" - I imagine there's a simpler watir way  :-)
> >
> > Thanks,
> >
> > Warren
> > _______________________________________________
> > Wtr-general mailing list
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-general
> >
>
> _______________________________________________
> Wtr-general mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

_____________________
 Bret Pettichord
 www.pettichord.com

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to