Topic: capturing errors using lambda

Wondering if anyone can give me a small hand with a bit of code:

im trying to locate elements on a page using webdriver, however when elements are not there it gives me a: ]

irb(main):026:0> browser.find_element(:id => 'id')
Selenium::WebDriver::Error::NoSuchElementError: Unable to locate element: {"method":"id","selector":"id"}

so im trying to write a method using to capture the error and return false something like

  def navigation_bar?
    if navigation_bar.nil? == false
       return true
       navigation_bar.nil? == true
       return false

i know i have to use lambda to capture the Selenium::WebDriver::Error::NoSuchElementError but am unsure what the syntax is?

Re: capturing errors using lambda

Sorry, I'm kinda new to ruby, but I wondered if one couldn't do so by "just" catching the Exception and returning the desired value if so?