Sha256: d1b972d0f3f521f1d37d44df79d7b64a2f57a6bc7f8cf306a3b65834cd0f5355

Contents?: true

Size: 748 Bytes

Versions: 17

Compression:

Stored size: 748 Bytes

Contents

class NodeFindError < Capybara::ElementNotFound

  def initialize(text, index, nodes)
    @text = text
    @index = index
    @nodes = nodes
  end

  def message
    if @nodes.empty?
      _not_found_at_all_message
    else
      if @index.present?
        _not_found_by_index_message
      else
        if @nodes.length > 1
          _need_index_message
        end
      end
    end
  end

  def _not_found_by_index_message
    "Element with text #{@text}[#{@index}] was not found on the page, " \
    "but #{@text}[0] found; Maybe used incorrect index?"
  end

  def _not_found_at_all_message
    "Element with text #{@text}[#{@index}] was not found on the page; " \
    "Maybe used incorrect text?"
  end

  def _need_index_message

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
pickles-0.2.4 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.2.3 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.2.2 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.2.1 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.2.0 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.12 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.10 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.9 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.8 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.7 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.6 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.5 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.4 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.3 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.2 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.1 lib/cucumber/pickles/errors/node_find_error.rb
pickles-0.1.0 lib/cucumber/pickles/errors/node_find_error.rb