1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Add xpath query for input type=button into XPath.button

This commit is contained in:
Pavel Gabriel 2010-02-19 02:29:53 +02:00
parent f1b84510b3
commit 9ad3ad3a25
3 changed files with 7 additions and 2 deletions

View file

@ -69,9 +69,9 @@ module Capybara
end
def button(locator)
xpath = append("//input[@type='submit' or @type='image'][@id=#{s(locator)} or contains(@value,#{s(locator)})]")
xpath = append("//input[@type='submit' or @type='image' or @type='button'][@id=#{s(locator)} or contains(@value,#{s(locator)})]")
xpath = xpath.append("//button[@id=#{s(locator)} or contains(@value,#{s(locator)}) or contains(.,#{s(locator)})]")
xpath = xpath.prepend("//input[@type='submit' or @type='image'][@value=#{s(locator)}]")
xpath = xpath.prepend("//input[@type='submit' or @type='image' or @type='button'][@value=#{s(locator)}]")
xpath = xpath.prepend("//button[@value=#{s(locator)} or text()=#{s(locator)}]")
end

View file

@ -138,6 +138,7 @@
</div>
<p>
<input type="button" name="form[fresh]" id="fresh_btn" value="i am fresh"/>
<input type="submit" name="form[awesome]" id="awe123" value="awesome"/>
<input type="submit" name="form[crappy]" id="crap321" value="crappy"/>
<input type="image" name="form[okay]" id="okay556" value="okay"/>

View file

@ -166,6 +166,10 @@ describe Capybara::XPath do
@driver.find(@query).first.value.should == 'click_me'
@query = @xpath.button('Click me!').to_s
@driver.find(@query).first.value.should == 'click_me'
@query = @xpath.button('fresh_btn').to_s
@driver.find(@query).first.value.should == 'i am fresh'
@query = @xpath.button('i am fresh').to_s
@driver.find(@query).first[:name].should == 'form[fresh]'
end
end