diff --git a/lib/capybara/node/actions.rb b/lib/capybara/node/actions.rb index 9702979d..9e7925d3 100644 --- a/lib/capybara/node/actions.rb +++ b/lib/capybara/node/actions.rb @@ -7,10 +7,19 @@ module Capybara # # Finds a button or link by id, text or value and clicks it. Also looks at image # alt text inside the link. + # @!macro waiting_behavior + # If the driver is capable of executing JavaScript, +$0+ will wait for a set amount of time + # and continuously retry finding the element until either the element is found or the time + # expires. The length of time +find+ will wait is controlled through {Capybara.default_max_wait_time} # - # @param [String] locator Text, id or value of link or button + # @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear. # - def click_link_or_button(locator, options={}) + # @overload click_link_or_button([locator], options) + # + # @param [String] locator Text, id or value of link or button + # + def click_link_or_button(locator=nil, options={}) + locator, options = nil, locator if locator.is_a? Hash find(:link_or_button, locator, options).click end alias_method :click_on, :click_link_or_button @@ -20,10 +29,14 @@ module Capybara # Finds a link by id, text or title and clicks it. Also looks at image # alt text inside the link. # - # @param [String] locator text, id, title or nested image's alt attribute - # @param options See {Capybara::Node::Finders#find_link} + # @macro waiting_behavior # - def click_link(locator, options={}) + # @overload click_link([locator], options) + # @param [String] locator text, id, title or nested image's alt attribute + # @param options See {Capybara::Node::Finders#find_link} + # + def click_link(locator=nil, options={}) + locator, options = nil, locator if locator.is_a? Hash find(:link, locator, options).click end @@ -34,9 +47,13 @@ module Capybara # \