I've used (a solution posted by you): @browser.tbody(:index, 0).rows.each_with_index do |row, index| row.cells.each do |cell| if cell.text == "some_text" puts @browser.tbody(:index, 0)[index] break end end end
It returns: #<Watir::TableRow:0x1214726>. I want to return the actual row index/number. I can do with a count but didn't wanted that approach. What i am trying to accomplish is to click delete/update (which id on url is generated dynamically) based on a cell which i can identify by text, therefore deleting/updating the corresponding row. Here is the UI => http://i52.tinypic.com/2yu12jd.png And DOM: => http://i53.tinypic.com/2bwo5t.png Any other approach would be welcome: Maybe something like (didn't get this work): @browser.td(:text => "text_name").td(:xpath => ""//a[@href=/delete/").click On May 5, 11:35 am, Željko Filipin <zeljko.fili...@wa-research.ch> wrote: > On Thu, May 5, 2011 at 10:31 AM, Dan Claudiu Pop <danclaudiu...@gmail.com> > wrote: > > > And also i tried with "each_with_index" but didn't get the expected > > What did you get and what did you expect? Please also provide your code. > > Rubydoc says watir-webdriver does not have a method with "index" in name: > > http://rubydoc.info/gems/watir-webdriver/ > > Željko > -- > watir.com - community manager > watir.com/book - author > watirpodcast.com - host > viaqa.mobi conference on software testing - organizer -- Before posting, please read http://watir.com/support. In short: search before you ask, be nice. watir-general@googlegroups.com http://groups.google.com/group/watir-general watir-general+unsubscr...@googlegroups.com