def wait_for_view(query,
                      timeout: Calabash::Wait.default_options[:timeout],
                      timeout_message: nil,
                      retry_frequency: Calabash::Wait.default_options[:retry_frequency])
      if query.nil?
        raise ArgumentError, 'Query cannot be nil'
      end

      timeout_message ||= lambda do |wait_options|
          "Waited #{wait_options[:timeout]} seconds for #{Wait.parse_query_list(query)} to match a view"
      end

      wait_for(timeout_message,
               timeout: timeout,
               retry_frequency: retry_frequency,
               exception_class: ViewNotFoundError) do
        result = query(query)
        !result.empty? && result
      end.first
    end
def wait_for_view(query,
                      timeout: Calabash::Wait.default_options[:timeout],
                      timeout_message: nil,
                      retry_frequency: Calabash::Wait.default_options[:retry_frequency])
      if query.nil?
        raise ArgumentError, 'Query cannot be nil'
      end

      timeout_message ||= lambda do |wait_options|
          "Waited #{wait_options[:timeout]} seconds for #{Wait.parse_query_list(query)} to match a view"
      end

      wait_for(timeout_message,
               timeout: timeout,
               retry_frequency: retry_frequency,
               exception_class: ViewNotFoundError) do
        result = query(query)
        !result.empty? && result
      end.first
    end
Waits for `query` to match one or more views.

 @example
  cal.wait_for_view({marked: 'mark'})

 @example
  cal.wait_for_view({marked: 'login'},
                  timeout_message: "Did not see login button")

 @example
  text = cal.wait_for_view("myview")['text']

 @see Calabash::Wait#wait_for for optional parameters

 @param [String, Hash, Calabash::Query] query Query to match view
 @return [Hash] The first view matching `query`.
 @raise [ViewNotFoundError] If `query` do not match at least one view.