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:
parent
1ed5d6fa81
commit
4a3cb69734
2 changed files with 8 additions and 0 deletions
|
@ -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) }
|
||||
|
|
|
@ -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'
|
||||
|
|
Loading…
Reference in a new issue