Method: Selenium::WebDriver::Support::Select#first_selected_option

Defined in:
lib/selenium/webdriver/support/select.rb

#first_selected_optionElement

Get the first selected option in this select element

Raises:

  • if no options are selected

Returns:



74
75
76
77
78
79
# File 'lib/selenium/webdriver/support/select.rb', line 74

def first_selected_option
  option = options.find(&:selected?)
  return option if option

  raise Error::NoSuchElementError, 'no options are selected'
end