diff --git a/lib/capybara/selector.rb b/lib/capybara/selector.rb index 9ef5d46d..e17fa768 100644 --- a/lib/capybara/selector.rb +++ b/lib/capybara/selector.rb @@ -185,7 +185,7 @@ end # @filter [String] :value Matches the value of an input button # Capybara.add_selector(:button) do - xpath(:value, :title) do |locator, **options| + xpath(:value, :title, :type) do |locator, **options| input_btn_xpath = XPath.descendant(:input)[XPath.attr(:type).one_of('submit', 'reset', 'image', 'button')] btn_xpath = XPath.descendant(:button) image_btn_xpath = XPath.descendant(:input)[XPath.attr(:type) == 'image'] diff --git a/lib/capybara/spec/session/has_button_spec.rb b/lib/capybara/spec/session/has_button_spec.rb index 5906a23b..44335cde 100644 --- a/lib/capybara/spec/session/has_button_spec.rb +++ b/lib/capybara/spec/session/has_button_spec.rb @@ -34,6 +34,11 @@ Capybara::SpecHelper.spec '#has_button?' do it "should be true for enabled buttons if disabled: :all" do expect(@session).to have_button('med', disabled: :all) end + + it "can verify button type" do + expect(@session).to have_button('awe123', type: 'submit') + expect(@session).not_to have_button('awe123', type: 'reset') + end end Capybara::SpecHelper.spec '#has_no_button?' do