Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-09-02 Thread Bret Pettichord

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
 Im 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
  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


_
 Bret Pettichord
 www.pettichord.com

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-09-01 Thread Warren Pollans
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
 Im 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
  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


Re: Re: Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-08-28 Thread Angrez Singh

 
Hi Bret,

Yes, we can provide the unittests once we are ready for the release, which we'll be doing very soon. We had modified the 'watir.rb' for adding the XPath support. So we need the latest 'watir.rb' so that we can do the neccessary changes.

Regards,
Angrez

On Wed, 24 Aug 2005 Bret Pettichord wrote :
At 09:04 AM 8/23/2005, Angrez Singh wrote:
We have been working on Watir to add XPath support for elements that can't (easily) be accessed using the attributes that are provided by Watir, but can be structurally addressed. A test version of that is ready which we have been testing and using internally; we plan to make it available to the larger Watir community if Bret, Paul et al think that it would be helpful. We had originally planned to do some more testing but if people might find it useful to have it available earlier we'll do it sooner.

This sounds interesting and useful. Can you also give us unit tests?


_
 Bret Pettichord
 www.pettichord.com

___
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] finding text in a cell that contains a specified image?

2005-08-19 Thread Warren Pollans
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
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-08-19 Thread Jeff Wood
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
 Im 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
  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
 


-- 
So long, and thanks for all the fish

Jeff Wood

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-08-19 Thread Jeff Wood
Bret,

My bad ... it's part of Ruby not you ... File.exist? and File.exists?

I knew I'd seen it recently ... just wasn't clear on WHERE.

Check the Std Lib docs ... under File#exist? and File#exists?
... exists? is marked obsolete.

j.

On 8/19/05, Bret Pettichord [EMAIL PROTECTED] wrote:
 At 11:28 AM 8/19/2005, Jeff Wood wrote:
 Oh, and exists? is deprecated (1.4), you should
 get used to exist?
 
 huh? we've always used 'exists?' in watir.
 
 
 _
   Bret Pettichord
   www.pettichord.com
 
 ___
 Wtr-general mailing list
 Wtr-general@rubyforge.org
 http://rubyforge.org/mailman/listinfo/wtr-general
 


-- 
So long, and thanks for all the fish

Jeff Wood

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general


Re: [Wtr-general] finding text in a cell that contains a specified image?

2005-08-19 Thread Bret Pettichord

At 12:47 PM 8/19/2005, Shao Kang Tat wrote:
So I'm assuming Watir will always start at index 0 when using .times 
do|x|is that right?  Would it be possible to make watir Know what 
iscalling .times so that it can start at a different index - in thiscase, 
tables?  I actually do use .times do|x| in some cases but Inever tried 
with tables until now because I assumed it would start atindex 0.

Shao


Ruby always starts at index 0.

We made a big mistake in designing Watir and used one-based indexing. The 
problems you are running into are consequences of our design error.


For example,

  ie.table(:name, 'foo')[2][3].text

is the same as

  ie.table(:name, 'foo').to_a[1][2]

This is because the first is 'watir' and the second is 'ruby', but we 
realize that everyday users will never be likely to figure this out.


We've discussed changing Watir to use zero-based indexing, but are 
concerned about compatability. Paul discussed this in a recent email. 
Comments? Anyone opposed to a switch?


Bret



_
 Bret Pettichord
 www.pettichord.com

___
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general