class Capybara::UI::Select

A select.

Public Instance Methods

get() click to toggle source

@return [String] The text of the selected option.

# File lib/capybara/ui/widgets/select.rb, line 26
def get
  selected.text unless selected.nil?
end
selected() click to toggle source
# File lib/capybara/ui/widgets/select.rb, line 5
def selected
  root.all(:xpath, ".//option", visible: true).select(&:selected?).first
end
set(option) click to toggle source

Selects the given option.

You may pass in the option text or value.

# File lib/capybara/ui/widgets/select.rb, line 38
def set(option)
  widget(:option, option).select
rescue
  begin
    widget(:option_by_value, option).select
  rescue Capybara::UI::MissingWidget => e
    raise InvalidOption.new(e.message).
      tap { |x| x.set_backtrace e.backtrace }
  end
end
to_cell() click to toggle source
# File lib/capybara/ui/widgets/select.rb, line 54
def to_cell
  get
end
value() click to toggle source

@return [String] The value of the selected option.

# File lib/capybara/ui/widgets/select.rb, line 31
def value
  selected.value unless selected.nil?
end