Class: Watir::SelectList
- Inherits:
-
InputElement
- Object
- Element
- InputElement
- Watir::SelectList
- Defined in:
- lib/watir-classic/input_elements.rb
Overview
Returned by Container#select_list.
Instance Attribute Summary
Attributes inherited from Element
Attributes included from Container
Instance Method Summary collapse
-
#clear ⇒ Object
Clear the selected options in the select list.
-
#include?(text_or_regexp) ⇒ Boolean
True when option with text includes in select list, false otherwise.
-
#multiple? ⇒ String, ...
Retrieve element’s multiple? from the OLE method.
-
#select(item) ⇒ Object
Select an item or items in a select box.
-
#select_value(item) ⇒ Object
Select an item or items in a select box by option’s value.
-
#selected?(text_or_regexp) ⇒ Boolean
True when option with text is selected in select list, false otherwise.
-
#selected_options ⇒ Array<OptionCollection>
Array of selected options.
Methods inherited from InputElement
#alt, #disabled?, #label, #name, #required?, #src, #type, #value
Methods inherited from Element
#<=>, #attribute_value, #class_name, #click, #disabled?, #double_click, #enabled?, #exists?, #fire_event, #flash, #focus, #focused?, #html, #id, #initialize, #inspect, #method_missing, #ole_object, #parent, #right_click, #send_keys, #style, #tag_name, #text, #title, #to_s, #to_subtype, #unique_number, #visible?
Methods included from DragAndDropHelper
#drag_and_drop_by, #drag_and_drop_on
Methods included from Container
#a, #abbr, #address, #alert, #area, #article, #aside, #audio, #b, #base, #bdi, #bdo, #blockquote, #body, #br, #button, #canvas, #caption, #checkbox, #cite, #code, #col, #colgroup, #command, #data, #datalist, #dd, #del, #details, #dfn, #div, #dl, #dt, #element, #em, #embed, #fieldset, #figcaption, #figure, #file_field, #font, #footer, #form, #frame, #frameset, #h1, #h2, #h3, #h4, #h5, #h6, #head, #header, #hgroup, #hidden, #hr, #i, #img, #input, #ins, #kbd, #keygen, #label, #legend, #li, #map, #mark, #menu, #meta, #meter, #modal_dialog, #nav, #noscript, #object, #ol, #optgroup, #option, #output, #p, #param, #pre, #progress, #q, #radio, #rp, #rt, #ruby, #s, #samp, #script, #section, #small, #source, #span, #strong, #style, #sub, #summary, #sup, #table, #tbody, #td, #text_field, #textarea, #tfoot, #th, #thead, #time, #title, #tr, #track, #u, #ul, #var, #video, #wbr
Methods included from Exception
Methods included from ElementExtensions
#present?, #wait_until_present, #wait_while_present, #when_present
Constructor Details
This class inherits a constructor from Watir::Element
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Watir::Element
Instance Method Details
#clear ⇒ Object
Clear the selected options in the select list.
33 34 35 36 37 |
# File 'lib/watir-classic/input_elements.rb', line 33 def clear perform_action do .each(&:clear) end end |
#include?(text_or_regexp) ⇒ Boolean
Returns true when option with text includes in select list, false otherwise.
83 84 85 |
# File 'lib/watir-classic/input_elements.rb', line 83 def include?(text_or_regexp) !.map(&:text).grep(text_or_regexp).empty? end |
#multiple? ⇒ String, ...
Retrieve element’s multiple? from the OLE method.
27 |
# File 'lib/watir-classic/input_elements.rb', line 27 attr_ole :multiple? |
#select(item) ⇒ Object
Select an item or items in a select box.
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/watir-classic/input_elements.rb', line 45 def select(item) = [] perform_action do = matching_items_in_select_list(:text, item) + matching_items_in_select_list(:label, item) + matching_items_in_select_list(:value, item) raise NoValueFoundException, "No option with :text, :label or :value of #{item.inspect} in this select element" if .empty? .each(&:select) end first_present_option_value , :text end |
#select_value(item) ⇒ Object
Select an item or items in a select box by option’s value.
63 64 65 66 67 68 |
# File 'lib/watir-classic/input_elements.rb', line 63 def select_value(item) = matching_items_in_select_list(:value, item) raise NoValueFoundException, "No option with :value of #{item.inspect} in this select element" if .empty? .each(&:select) first_present_option_value , :value end |
#selected?(text_or_regexp) ⇒ Boolean
Returns true when option with text is selected in select list, false otherwise.
91 92 93 94 |
# File 'lib/watir-classic/input_elements.rb', line 91 def selected?(text_or_regexp) raise UnknownObjectException, "Option #{text_or_regexp.inspect} not found." unless include? text_or_regexp !.map(&:text).grep(text_or_regexp).empty? end |
#selected_options ⇒ Array<OptionCollection>
Returns array of selected options.
75 76 77 |
# File 'lib/watir-classic/input_elements.rb', line 75 def .select(&:selected?) end |