Method: Celerity::SelectList#select_value

Defined in:
lib/celerity/elements/select_list.rb

#select_value(value) ⇒ String

Selects the option(s) whose value attribute matches the given string.

Parameters:

  • value (String, Regexp)

    A value.

Returns:

  • (String)

    The option selected. If multiple options match, returns the first match

Raises:



68
69
70
71
72
73
74
75
76
77
# File 'lib/celerity/elements/select_list.rb', line 68

def select_value(value)
  assert_exists
  selected = @object.getOptions.map { |e| e.click if Util.matches?(e.getValueAttribute, value) }.compact.first

  unless selected
    raise NoValueFoundException, "unknown option with value #{value.inspect} for select_list #{@conditions.inspect}"
  end

  selected.asText
end