# frozen_string_literal: true module Capybara module Node module Actions # @!macro waiting_behavior # If the driver is capable of executing JavaScript, this method 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 this method will wait is controlled through {Capybara.configure default_max_wait_time}. # # @option options [false, true, Numeric] wait # Maximum time to wait for matching element to appear. Defaults to {Capybara.configure default_max_wait_time}. ## # # Finds a button or link and clicks it. See {#click_button} and # {#click_link} for what locator will match against for each type of element. # # @overload click_link_or_button([locator], **options) # @macro waiting_behavior # @param [String] locator See {#click_button} and {#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, {Capybara.configure test_id} attribute, text or title and clicks it. Also looks at image # alt text inside the link. # # @overload click_link([locator], **options) # @macro waiting_behavior # @param [String] locator text, id, {Capybara.configure test_id} attribute, title or nested image's alt attribute # @param [Hash] 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 # `