How to check if element NOT exist in iOS app using Appium and Ruby?

Hi,

I want to check if a element NOT exist on my screen and if it is on the screen I would like to raise an Error. I was trying us the code below but this raises me an

 (Selenium::WebDriver::Error::NoSuchElementError)

object= $driver.find_element(:id,“t3_wallet_button”)

  if (object != nil)
    puts 'ERROR'
#    MinitestWorld.assert(false, "ERROR MESSAGE")
  end

  if (object == nil)
    puts 'NO ERROR'
  end

could someone help me on this please?

Thanks!

I find a solution already:

begin
login_button_displayed = $driver.find_element(:id,“t3_wallet_button”).displayed?
rescue
login_button_displayed = false
end

  if(login_button_displayed == true)
    MinitestWorld.assert(false, "ERROR")

  end

you can also do something like

def element_exists_by_id?(my_id)
    if find_elements(:id,my_id).size == 0
        false
    else
        true
    end
end
object= $driver.find_element(:id,"t3_wallet_button")
element_proc = Proc.new {  object }

def is_present(element_proc)
  begin
    return true if element_proc.call
  rescue
    return false
  end
end

how to do the exact thing for node js client?