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 = [], offset = {}) ⇒ Object

Raises:

  • (ArgumentError)


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

def click(keys = [], offset = {})
  raise ArgumentError, "The mechanize driver does not support click options" unless keys.empty? && offset.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))
    if Capybara::VERSION > '3.0.0'
      super
    else
      super()
    end
  elsif submits
    associated_form = form
    Capybara::Mechanize::Form.new(driver, form).submit(self) if associated_form
  else
    super
  end
end