Method: Webrat::SeleniumSession#click_button

Defined in:
lib/webrat/selenium/selenium_session.rb

#click_button(button_text_or_regexp = nil, options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/webrat/selenium/selenium_session.rb', line 66

def click_button(button_text_or_regexp = nil, options = {})
  if button_text_or_regexp.is_a?(Hash) && options == {}
    pattern, options = nil, button_text_or_regexp
  elsif button_text_or_regexp
    pattern = adjust_if_regexp(button_text_or_regexp)
  end
  pattern ||= '*'
  locator = "button=#{pattern}"

  selenium.wait_for_element locator, :timeout_in_seconds => 5
  selenium.click locator
end