Class: NodeFindError

Inherits:
Capybara::ElementNotFound
  • Object
show all
Defined in:
lib/cucumber/pickles/errors/node_find_error.rb

Instance Method Summary collapse

Constructor Details

#initialize(text, index, nodes) ⇒ NodeFindError

Returns a new instance of NodeFindError.



3
4
5
6
7
# File 'lib/cucumber/pickles/errors/node_find_error.rb', line 3

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

Instance Method Details

#_need_index_messageObject



33
34
35
# File 'lib/cucumber/pickles/errors/node_find_error.rb', line 33

def _need_index_message

end

#_not_found_at_all_messageObject



28
29
30
31
# File 'lib/cucumber/pickles/errors/node_find_error.rb', line 28

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

#_not_found_by_index_messageObject



23
24
25
26
# File 'lib/cucumber/pickles/errors/node_find_error.rb', line 23

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

#messageObject



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/cucumber/pickles/errors/node_find_error.rb', line 9

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