Ruby selenium script waiting for an element to disappear
Some notes:


waitUntilDisappears. In Ruby, always: wait_until_disappears.
if element != nil -> if element.
if element != nil. I think find_element never returns nil, it raises exception if not found, so this is not needed.
rescue Exception =&gt; e. A rescue that covers a whole method can omit the begin.
rescue Exception =&gt; e. Rescuing from Exception is bad practice. Rescue from StandardError, which is the same as rescue =&gt; e.
puts "Error". It's bad practice to catch an exception (even worse ifit's all exceptions), just print to the screen and return as if nothing happened. Raise an exception or return a value that signals the error.
Is Element#visible? not enough?


I'd write:

def wait_until_disappears(type, name, timeout: 5)
  wait = Selenium::WebDriver::Wait.new(timeout: timeout)
  wait.until { !driver.find_element(type, name).visible? }
end