Skip to content

Commit 89c1017

Browse files
committed
Expand click_on beyond just an alias of click_link_or_button
1 parent 94f7f88 commit 89c1017

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

lib/capybara/node/actions.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,31 @@ module Actions
2424
def click_link_or_button(locator = nil, **options)
2525
find(:link_or_button, locator, options).click
2626
end
27-
alias_method :click_on, :click_link_or_button
27+
28+
##
29+
#
30+
# Finds an element and clicks on it
31+
#
32+
# By default this is an alias of {Capybara::Node::Actions#click_llink_or_button}
33+
# @overload click_on([locator], **options)
34+
# By default this is an alias of {Capybara::Node::Actions#click_link_or_button}
35+
# @macro waiting_behavior
36+
# @param [String] locator See {Capybara::Node::Actions#click_button} and {Capybara::Node::Actions#click_link}
37+
#
38+
# @overload click_on(selector, [locator], **options)
39+
# @macro waiting_behavior
40+
# @param [Symbol] symbol A registered selector type (:css, :xpath, :element, ...) See {Capybara::Selector} for built-in selectors.
41+
# @param [String] locator See {Capybara::Selector} for locator specifics
42+
#
43+
# @return [Capybara::Node::Element] The element clicked
44+
#
45+
def click_on(*args, **options)
46+
if args[0].is_a?(Symbol)
47+
find(*args, **options).click
48+
else
49+
click_link_or_button(*args, **options)
50+
end
51+
end
2852

2953
##
3054
#

0 commit comments

Comments
 (0)