Method: Webrat::Locators::SelectOptionLocator#locate

Defined in:
lib/webrat/core/locators/select_option_locator.rb

#locateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/webrat/core/locators/select_option_locator.rb', line 16

def locate
  if @id_or_name_or_label
    field = FieldLocator.new(@session, @dom, @id_or_name_or_label, SelectField).locate!
    
    field.options.detect do |o|
      if @option_text.is_a?(Regexp)
        Webrat::XML.inner_html(o.element) =~ @option_text
      else
        Webrat::XML.inner_html(o.element) == @option_text.to_s
      end
    end
  else
    option_element = option_elements.detect do |o|
      if @option_text.is_a?(Regexp)
        Webrat::XML.inner_html(o) =~ @option_text
      else
        Webrat::XML.inner_html(o) == @option_text.to_s
      end
    end
    
    SelectOption.load(@session, option_element)
  end
end