Extract LabelLocator
This commit is contained in:
parent
f6a9bed41e
commit
4ae94af45c
|
@ -99,10 +99,9 @@ module Webrat
|
|||
end
|
||||
|
||||
def find_field_id_for_label(label_text) #:nodoc:
|
||||
# TODO - Convert to using elements
|
||||
require "webrat/core/locators/label_locator"
|
||||
|
||||
label = forms.detect_mapped { |form| form.label_matching(label_text) }
|
||||
if label
|
||||
if (label = LabelLocator.new(self, label_text).locate)
|
||||
label.for_id
|
||||
else
|
||||
raise NotFoundError.new("Could not find the label with text #{label_text}")
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
require "webrat/core/locators/locator"
|
||||
|
||||
module Webrat
|
||||
module Locators
|
||||
|
||||
class LabelLocator < Locator
|
||||
|
||||
def locate
|
||||
# TODO - Convert to using elements
|
||||
|
||||
@scope.send(:forms).detect_mapped do |form|
|
||||
form.label_matching(@value)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue