Method: Capybara::Node::Actions#select
- Defined in:
- lib/capybara/node/actions.rb
#select(value = nil, from: nil, **options) ⇒ Capybara::Node::Element
If from
option is present, #select finds a select box, or text input with associated datalist,
on the page and selects a particular option from it.
Otherwise it finds an option inside current scope and selects it.
If the select box is a multiple select, #select can be called multiple times to select more than
one option.
The select box can be found via its name, id, test_id attribute, or label text.
The option can be found by its text.
page.select 'March', from: 'Month'
201 202 203 204 205 206 207 208 209 210 211 |
# File 'lib/capybara/node/actions.rb', line 201 def select(value = nil, from: nil, **) raise ArgumentError, 'The :from option does not take an element' if from.is_a? Capybara::Node::Element el = from ? find_select_or_datalist_input(from, ) : self if el.respond_to?(:tag_name) && (el.tag_name == 'input') select_datalist_option(el, value) else el.find(:option, value, **).select_option end end |