# frozen_string_literal: true module Capybara module Node module Actions ## # # 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} # # @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 Text, id or value of link or button # # @return [Capybara::Node::Element] The element clicked # 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 ## # # 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={}) locator, options = nil, locator if locator.is_a? Hash 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 # \