May be semantics, but you mentioned clicking on a link to call a button, which
could be a problem if the element truly is a link. If it's a link then you
should try to access it that way:
book_rows.a(value: /view/i).click.
There might be more than one table with that id:
@browser.tables(id: /academic/i).length
Not sure if this'll help or not but you can try something like it with your
table object and maybe it'll help you see what's going on:
table.trs.to_a.each_with_index do |tr, idx| puts
"---------------------------------" puts "INDEX:\t#{idx}" puts
"TEXT\t#{tr.text}" puts "BUTTONS\t#{tr.buttons.length}" puts
"BVALS:\t'#{tr.buttons.map(&:value).map(&:value).join(', ')}'" puts
"LINKS\t#{tr.as.length}" puts
"LVALS:\t'#{tr.as.map(&:text).map(&:value).join(', ')}'"end
From: 江南 <[email protected]>
To: Watir General <[email protected]>
Sent: Sunday, December 25, 2016 8:36 AM
Subject: [wtr-general] How to click specific link in table?
Hi,
I want to click on a specific link in a table:
boo_title = 'Learn driving'
table = @browser.table(:id => 'Academic')
book_row = table.td(:text => book_title).parent
book_row.button(:value => 'View').click
but currently Im getting this error:Watir::Exception::UnknownObjectException:
unable to locate element, using {:text=>"Learn driving", :tag_name=>"td"}
Please help!--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
--
Before posting, please read http://watir.com/support. In short: search before
you ask, be nice.
[email protected]
http://groups.google.com/group/watir-general
[email protected]
---
You received this message because you are subscribed to the Google Groups
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.