Class: CapybaraPageObject::SelectListElement
- Inherits:
-
Element
- Object
- Element
- CapybaraPageObject::SelectListElement
show all
- Defined in:
- lib/capybara_page_object/elements/select_list_element.rb
Instance Attribute Summary
Attributes inherited from Element
#element, #page
Instance Method Summary
collapse
Methods inherited from Element
#attribute, #class, #enabled?, #focus, #html, #initialize, #method_missing, #native, #parent, #respond_to_missing?, #scroll_into_view, #within
Instance Method Details
#clear ⇒ Object
16
17
18
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 16
def clear
selected_options.each(&:unselect_option)
end
|
#select_value(value) ⇒ Object
26
27
28
29
30
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 26
def select_value(value)
within do
all(:css, "option[@value=#{value}]").each(&:select_option)
end
end
|
#selected?(value_or_text) ⇒ Boolean
4
5
6
7
8
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 4
def selected?(value_or_text)
option = selected_option
option.value == value_or_text ||
option.text == value_or_text
end
|
#selected_option ⇒ Object
10
11
12
13
14
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 10
def selected_option
within do
first('option[selected]')
end
end
|
#selected_options ⇒ Object
20
21
22
23
24
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 20
def selected_options
within do
all('option[selected]')
end
end
|
#selected_values ⇒ Object
32
33
34
|
# File 'lib/capybara_page_object/elements/select_list_element.rb', line 32
def selected_values
selected_options.map(&:value)
end
|