Here's another way that might work:

#This should return either an object or nil
result = @browser.table(:index, 3).links.find {|tr| tr.text == link_name}

result.click unless result.nil? 





________________________________
 From: Joe Fl <[email protected]>
To: [email protected] 
Sent: Monday, October 1, 2012 11:16 AM
Subject: [wtr-general] Using ternary operator with Watir
 

Hi everyone,

I am experimenting with the ruby and I would like to know if I could include a 
'break' in the loop below once the link
is clicked.

I have tried a couple of ideas but they just ended in a syntax error.

@browser.table(:index,3).links.each{|tr| puts tr.text == link_name ? 
(@browser.a(:text,tr.text).click) : (puts "Not fiond")}


Any help would be greatly appreciated.

Thank you,
Joe
-- 
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]

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

Reply via email to