Or even
result.click if result

But i would drop the #find call also and use just Watir API:
result = @browser.table(:index, 3).link(:text => link_name)
result.click if result.exists?

Jarmo Pertman
-----
IT does really matter - http://itreallymatters.net


On Tuesday, October 2, 2012 6:47:30 AM UTC+3, Oscar.Rieken wrote:
>
>
> http://railstips.org/blog/archives/2008/12/01/unless-the-abused-ruby-conditional/
>
> if result
>   result.click
> end 
>
>
> On Mon, Oct 1, 2012 at 3:57 PM, John Fitisoff <jfit...@yahoo.com<javascript:>
> > wrote:
>
>> 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 <joefl...@gmail.com <javascript:>>
>> *To:* watir-...@googlegroups.com <javascript:> 
>> *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.
>>  
>> watir-...@googlegroups.com <javascript:>
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com <javascript:>
>>
>>
>>   -- 
>> Before posting, please read http://watir.com/support. In short: search 
>> before you ask, be nice.
>>  
>> watir-...@googlegroups.com <javascript:>
>> http://groups.google.com/group/watir-general
>> watir-genera...@googlegroups.com <javascript:>
>>
>
>

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