Class: Capybara::Mechanize::Node

Inherits:
RackTest::Node
  • Object
show all
Defined in:
lib/capybara/mechanize/node.rb

Instance Method Summary collapse

Instance Method Details

#click(keys = [], **options) ⇒ Object

Raises:

  • (ArgumentError)


4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/capybara/mechanize/node.rb', line 4

def click(keys = [], **options)
  options.delete(:offset)
  raise ArgumentError, 'The mechanize driver does not support click options' unless keys.empty? && options.empty?

  submits = respond_to?(:submits?) ? submits? :
    ((tag_name == 'input' and %w[submit image].include?(type)) or
      ((tag_name == 'button') and type.nil? or type == 'submit'))

  if tag_name == 'a' or tag_name == 'label' or
      (tag_name == 'input' and %w[checkbox radio].include?(type))
    Capybara::VERSION > '3.0.0' ? super : super()
  elsif submits
    associated_form = form
    Capybara::Mechanize::Form.new(driver, form).submit(self) if associated_form
  else
    super
  end
end