Class: Webrat::Locators::SelectOptionLocator
Overview
:nodoc:
Instance Method Summary (collapse)
- - (Object) error_message
-
- (SelectOptionLocator) initialize(session, dom, option_text, id_or_name_or_label)
constructor
A new instance of SelectOptionLocator.
- - (Object) locate
- - (Object) option_elements
Methods inherited from Locator
Constructor Details
- (SelectOptionLocator) initialize(session, dom, option_text, id_or_name_or_label)
A new instance of SelectOptionLocator
9 10 11 12 13 14 |
# File 'lib/webrat/core/locators/select_option_locator.rb', line 9 def initialize(session, dom, option_text, id_or_name_or_label) @session = session @dom = dom @option_text = option_text @id_or_name_or_label = id_or_name_or_label end |
Instance Method Details
- (Object) error_message
44 45 46 47 48 49 50 |
# File 'lib/webrat/core/locators/select_option_locator.rb', line 44 def if @id_or_name_or_label "The '#{@option_text}' option was not found in the #{@id_or_name_or_label.inspect} select box" else "Could not find option #{@option_text.inspect}" end end |
- (Object) locate
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, MultipleSelectField).locate! field..detect do |o| if @option_text.is_a?(Regexp) o.element.inner_text =~ @option_text else o.inner_text == @option_text.to_s end end else option_element = option_elements.detect do |o| if @option_text.is_a?(Regexp) o.inner_text =~ @option_text else o.inner_text == @option_text.to_s end end SelectOption.load(@session, option_element) end end |
- (Object) option_elements
40 41 42 |
# File 'lib/webrat/core/locators/select_option_locator.rb', line 40 def option_elements @dom.xpath(*SelectOption.xpath_search) end |