diff --git a/lib/webrat/core/elements/field.rb b/lib/webrat/core/elements/field.rb index 359e69a..bcc46ef 100644 --- a/lib/webrat/core/elements/field.rb +++ b/lib/webrat/core/elements/field.rb @@ -365,11 +365,7 @@ module Webrat end def options - option_elements.map { |oe| SelectOption.new(@session, oe) } - end - - def option_elements - Webrat::XML.css_search(@element, "option") + @options ||= SelectOption.load_all(@session, @element) end end diff --git a/lib/webrat/core/elements/select_option.rb b/lib/webrat/core/elements/select_option.rb index d10a153..161e6ba 100644 --- a/lib/webrat/core/elements/select_option.rb +++ b/lib/webrat/core/elements/select_option.rb @@ -3,6 +3,10 @@ require "webrat/core/elements/element" module Webrat class SelectOption < Element #:nodoc: + def self.xpath_search + ".//option" + end + def matches_text?(text) if text.is_a?(Regexp) Webrat::XML.inner_html(@element) =~ text