def try_for(timeout = 30, polling_interval = 1, &block)
      start_time = Time.now

      last_error = nil
      until (duration = Time.now - start_time) > timeout
        begin
          yield
          last_error = nil
					return true 
        rescue => e
          last_error = e
        end
        sleep polling_interval
      end

      raise "Timeout after #{duration.to_i} seconds with error: #{last_error}." if last_error
      raise "Timeout after #{duration.to_i} seconds."
    end
def try_for(timeout = 30, polling_interval = 1, &block)
      start_time = Time.now

      last_error = nil
      until (duration = Time.now - start_time) > timeout
        begin
          yield
          last_error = nil
					return true 
        rescue => e
          last_error = e
        end
        sleep polling_interval
      end

      raise "Timeout after #{duration.to_i} seconds with error: #{last_error}." if last_error
      raise "Timeout after #{duration.to_i} seconds."
    end
TODO: save as file dialog
 helper
 Try the operation up to specified timeout (in seconds), and sleep given interval (in seconds).
 Error will be ignored until timeout
 Example
    try_for { click_link('waiting')}
    try_for (10, 2) { click_button('Search' } # try to click the 'Search' button upto 10 seconds, try every 2 seconds
    try_for { click_button('Search' }