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

Correct problem with partial matches

This commit is contained in:
Jonas Nicklas 2009-12-09 21:53:12 +01:00
parent ac357b8e11
commit ae48b83ded
2 changed files with 5 additions and 3 deletions

View file

@ -84,7 +84,7 @@ module Capybara
def add_field(locator) def add_field(locator)
xpath = append(yield(s(locator))) xpath = append(yield(s(locator)))
xpath.append(yield("//label[contains(.,#{s(locator)})]/@for")) xpath = xpath.append(yield("//label[contains(.,#{s(locator)})]/@for"))
xpath.prepend(yield("//label[text()=#{s(locator)}]/@for")) xpath.prepend(yield("//label[text()=#{s(locator)}]/@for"))
end end

View file

@ -2,8 +2,10 @@
<form action="/form" method="post"> <form action="/form" method="post">
<p> <p>
<label for="form_first_name">First Name</label> <label for="form_first_name">
First Name
<input type="text" name="form[first_name]" value="John" id="form_first_name"/> <input type="text" name="form[first_name]" value="John" id="form_first_name"/>
</label>
</p> </p>
<p> <p>