field_labeled() should disregard labels without matching fields
This commit is contained in:
parent
cbd323ac37
commit
2b38b78724
@ -68,6 +68,7 @@
|
||||
|
||||
* Bug fixes
|
||||
|
||||
* field_labeled should disregard labels without matching fields (Kyle Hargraves)
|
||||
* Fixed bug where Scope was creating a new DOM rather than re-using the existing DOM.
|
||||
[#105] (Zach Dennis)
|
||||
* Support Rails > v2.2 by using ActionController::RequestParser for param parsing [#107]
|
||||
|
@ -7,7 +7,7 @@ module Webrat
|
||||
class FieldLabeledLocator < Locator # :nodoc:
|
||||
|
||||
def locate
|
||||
matching_labels.any? && matching_labels.first.field
|
||||
matching_labels.any? && matching_labels.detect_mapped { |label| label.field }
|
||||
end
|
||||
|
||||
def matching_labels
|
||||
|
@ -139,4 +139,19 @@ describe "field_labeled" do
|
||||
should_raise_error_matching /Could not find .* "Other Label"/, :for => "Other Label"
|
||||
end
|
||||
|
||||
describe "finding a field when labels without fields also match" do
|
||||
using_this_html <<-HTML
|
||||
<html>
|
||||
<label>The Label</label>
|
||||
<form>
|
||||
<label for="element_42">The Label</label>
|
||||
<input type="text" id="element_42">
|
||||
</form>
|
||||
</html>
|
||||
HTML
|
||||
|
||||
should_return_a Webrat::TextField, :for => "The Label"
|
||||
with_an_id_of "element_42", :for => "The Label"
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user