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

Added id selector

This commit is contained in:
Jonas Nicklas 2010-08-20 14:46:56 +02:00
parent 1ed5d6fa81
commit 4a3cb69734
2 changed files with 8 additions and 0 deletions

View file

@ -80,4 +80,5 @@ Capybara.configure do |config|
end
Capybara.add_selector(:xpath) { |xpath| xpath }
Capybara.add_selector(:id) { |id| XPath.generate { |x| x.descendant(:*)[x.attr(:id) == id] } }
Capybara.add_selector(:css) { |css| XPath::HTML.from_css(css) }

View file

@ -42,6 +42,13 @@ shared_examples_for "find" do
end
end
context "with id selectors" do
it "should find the first element using the given locator" do
@session.find(:id, 'john_monkey').text.should == 'Monkey John'
@session.find(:id, 'red').text.should == 'Redirect'
end
end
context "with xpath selectors" do
it "should find the first element using the given locator" do
@session.find(:xpath, '//h1').text.should == 'This is a test'