On Mar 17, 5:41 am, Aravind <aravindredd...@gmail.com> wrote:
> thanks for the suggestion and this is the code i used
>
> def clickaction(table_id)
>   table = $b.table(:id,table_id)
>   if table.row_count > 2
>     for i in 3..table.row_count - 1
>       if table[i][8].text == "APV"
>          table[i][1].link(:index,1).click
>       end
>     end
>   end
> end

Perhaps we can clean that up a little.

If APV appears nowhere else in the table as the contents of a single
cell, then you could try

If browser.table(:id, table_id).cell(:text, "APV").exists?
  browser.table(:id, table_id).cell(:text, "APV").parent.link(:index,
1).click
end

Parent should in that case give you the row that contains that cell,
and if the link is the first link in the first cell, then it should be
the first link in the row.

If APV can appear more than once, and you just want the first one in
any case then

If browser.table(:id, table_id).cell(:text => "APV", :index =>
1).exists?
  browser.table(:id, table_id).cell:text => "APV", :index =>
1).parent.link(:index, 1).click
end

Give it a try from IRB and see if that works.

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

Reply via email to