I had a nedd to write something like this a while back. I was intending
to do a generic thing, maybe like

ie.table(:index,2).find_cell_that_contains(:image , {:src =>
/mypic.gif/} )

In the end I did something different. But I think this would be a useful
addition.

Paul

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeff Wood
Sent: 19 August 2005 10:29
To: [email protected]
Subject: Re: [Wtr-general] finding text in a cell that contains a
specifiedimage?


I know it's a user preference game, but it's much more "the ruby way" to
stay away from "for ... in ... " ... also, your range starts @ 1 ...
what about row 0 ? Oh, and exists? is deprecated (1.4), you should get
used to exist?

how about, 

t.row_count.times do |i|
  theCell = t[i].find { |c| c.image( :src, xxx ).exist? }
  return theCell.text.strip if theCell
end

anyways, comments are welcome.

j.

On 8/19/05, Shao Kang Tat <[EMAIL PROTECTED]> 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
> 


-- 
"So long, and thanks for all the fish"

Jeff Wood

_______________________________________________
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

Reply via email to