# frozen_string_literal: true module Capybara module Node module Actions ## # # Finds a button or link and clicks it. See {Capybara::Node::Actions#click_button} and # {Capybara::Node::Actions#click_link} for what locator will match against for each type of element # @!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} # # @option options [false, Numeric] wait (Capybara.default_max_wait_time) Maximum time to wait for matching element to appear. # # @overload click_link_or_button([locator], options) # # @param [String] locator See {Capybara::Node::Actions#click_button} and {Capybara::Node::Actions#click_link} # # @return [Capybara::Node::Element] The element clicked # def click_link_or_button(locator=nil, **options) find(:link_or_button, locator, options).click end alias_method :click_on, :click_link_or_button ## # # Finds a link by id, text or title and clicks it. Also looks at image # alt text inside the link. # # @macro waiting_behavior # # @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} # # @return [Capybara::Node::Element] The element clicked def click_link(locator=nil, **options) find(:link, locator, options).click end ## # # Finds a button on the page and clicks it. # This can be any \ element of type submit, reset, image, button or it can be a # \