Class: Watir::Option
- Inherits:
-
HTMLElement
- Object
- Element
- HTMLElement
- Watir::Option
- Defined in:
- lib/watir-webdriver/elements/option.rb,
lib/watir-webdriver/elements/generated.rb
Overview
Represents an option in a select list.
Constant Summary
Constants included from Atoms
Instance Method Summary collapse
-
#clear ⇒ Object
Clears (i.e. toggles selected state) option.
-
#default_selected? ⇒ Boolean
Value of defaultSelected property.
-
#disabled? ⇒ Boolean
Value of disabled property.
-
#form ⇒ String
Value of form property.
-
#index ⇒ Fixnum
Value of index property.
-
#label ⇒ String
Value of label property.
-
#select ⇒ Object
Selects this option.
-
#selected? ⇒ Boolean
Value of selected property.
-
#text ⇒ String
Returns the text of option.
-
#toggle ⇒ Object
Toggles the selected state of this option.
-
#value ⇒ String
Value of value property.
Methods inherited from HTMLElement
#access_key, #access_key_label, #command_checked?, #command_disabled?, #command_hidden?, #command_icon, #command_label, #command_type, #content_editable, #content_editable?, #context_menu, #dataset, #dir, #draggable?, #dropzone, #hidden?, #item_id, #item_prop, #item_ref, #item_scope?, #item_type, #item_value, #lang, #onabort, #onautocomplete, #onautocompleteerror, #onblur, #oncancel, #oncanplay, #oncanplaythrough, #onchange, #onclick, #onclose, #oncontextmenu, #oncuechange, #ondblclick, #ondrag, #ondragend, #ondragenter, #ondragexit, #ondragleave, #ondragover, #ondragstart, #ondrop, #ondurationchange, #onemptied, #onended, #onerror, #onfocus, #oninput, #oninvalid, #onkeydown, #onkeypress, #onkeyup, #onload, #onloadeddata, #onloadedmetadata, #onloadstart, #onmousedown, #onmouseenter, #onmouseleave, #onmousemove, #onmouseout, #onmouseover, #onmouseup, #onmousewheel, #onpause, #onplay, #onplaying, #onprogress, #onratechange, #onreset, #onresize, #onscroll, #onseeked, #onseeking, #onselect, #onshow, #onsort, #onstalled, #onsubmit, #onsuspend, #ontimeupdate, #ontoggle, #onvolumechange, #onwaiting, #properties, #spellcheck?, #tab_index, #title, #translate?
Methods inherited from Element
#==, #attribute_value, #browser, #class_name, #click, #double_click, #drag_and_drop_by, #drag_and_drop_on, #driver, #exists?, #fire_event, #flash, #focus, #focused?, #hash, #hover, #id, #initialize, #inner_html, #inspect, #outer_html, #parent, #present?, #right_click, #run_checkers, #select_text, #send_keys, #style, #tag_name, #to_subtype, #visible?, #wd
Methods included from AttributeHelper
#attribute, #attribute_list, #inherit_attributes_from, #method, #typed_attributes
Methods included from EventuallyPresent
#wait_until_present, #wait_while_present, #when_present
Methods included from Container
#a, #abbr, #abbrs, #address, #addresses, #area, #areas, #article, #articles, #as, #aside, #asides, #audio, #audios, #b, #base, #bases, #bdi, #bdis, #bdo, #bdos, #blockquote, #blockquotes, #body, #bodys, #br, #brs, #bs, #button, #buttons, #canvas, #canvases, #caption, #captions, #checkbox, #checkboxes, #cite, #cites, #code, #codes, #col, #colgroup, #colgroups, #cols, #data, #datalist, #datalists, #datas, #dd, #dds, #del, #dels, #details, #detailses, #dfn, #dfns, #dialog, #dialogs, #div, #divs, #dl, #dls, #dt, #dts, #element, #elements, #em, #embed, #embeds, #ems, #extract_selector, #field_set, #field_sets, #fieldset, #fieldsets, #figcaption, #figcaptions, #figure, #figures, #file_field, #file_fields, #font, #fonts, #footer, #footers, #forms, #frame, #frames, #frameset, #framesets, #h1, #h1s, #h2, #h2s, #h3, #h3s, #h4, #h4s, #h5, #h5s, #h6, #h6s, #head, #header, #headers, #heads, #hgroup, #hgroups, #hidden, #hiddens, #hr, #hrs, #html, #htmls, #i, #iframe, #iframes, #image, #images, #img, #imgs, #input, #inputs, #ins, #inses, #is, #kbd, #kbds, #keygen, #keygens, #labels, #legend, #legends, #li, #link, #links, #lis, #main, #mains, #map, #maps, #mark, #marks, #menu, #menuitem, #menuitems, #menus, #meta, #metas, #meter, #meters, #nav, #navs, #noscript, #noscripts, #object, #objects, #ol, #ols, #optgroup, #optgroups, #option, #options, #output, #outputs, #p, #param, #params, #pre, #pres, #progress, #progresses, #ps, #q, #qs, #radio, #radios, #rp, #rps, #rt, #rts, #rubies, #ruby, #s, #samp, #samps, #script, #scripts, #section, #sections, #select_list, #select_lists, #selects, #small, #smalls, #source, #sources, #span, #spans, #ss, #strong, #strongs, #style, #styles, #sub, #subs, #summaries, #summary, #sup, #sups, #table, #tables, #tbody, #tbodys, #td, #tds, #template, #templates, #text_field, #text_fields, #textarea, #textareas, #tfoot, #tfoots, #th, #thead, #theads, #ths, #time, #times, #title, #titles, #tr, #track, #tracks, #trs, #u, #ul, #uls, #us, #var, #vars, #video, #videos, #wbr, #wbrs
Methods included from Atoms
Methods included from XpathSupport
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
Clears (i.e. toggles selected state) option.
41 42 43 |
# File 'lib/watir-webdriver/elements/option.rb', line 41 def clear @element.click if selected? end |
#default_selected? ⇒ Boolean
Returns value of defaultSelected property.
372 |
# File 'lib/watir-webdriver/elements/generated.rb', line 372 attribute("Boolean", :default_selected?, :defaultSelected) |
#disabled? ⇒ Boolean
Returns value of disabled property.
369 |
# File 'lib/watir-webdriver/elements/generated.rb', line 369 attribute("Boolean", :disabled?, :disabled) |
#form ⇒ String
Returns value of form property.
370 |
# File 'lib/watir-webdriver/elements/generated.rb', line 370 attribute(String, :form, :form) |
#index ⇒ Fixnum
Returns value of index property.
375 |
# File 'lib/watir-webdriver/elements/generated.rb', line 375 attribute(Fixnum, :index, :index) |
#label ⇒ String
Returns value of label property.
371 |
# File 'lib/watir-webdriver/elements/generated.rb', line 371 attribute(String, :label, :label) |
#select ⇒ Object
Selects this option.
17 18 19 20 |
# File 'lib/watir-webdriver/elements/option.rb', line 17 def select assert_exists @element.click end |
#selected? ⇒ Boolean
Returns value of selected property.
51 52 53 54 |
# File 'lib/watir-webdriver/elements/option.rb', line 51 def selected? assert_exists @element.selected? end |
#text ⇒ String
Returns the text of option.
Note that the text is either one of the following respectively:
* label attribute
* text attribute
* inner element text
67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/watir-webdriver/elements/option.rb', line 67 def text assert_exists # A little unintuitive - we'll return the 'label' or 'text' attribute if # they exist, otherwise the inner text of the element attribute = [:label, :text].find { |a| attribute? a } if attribute @element.attribute(attribute) else @element.text end end |
#toggle ⇒ Object
Toggles the selected state of this option.
29 30 31 32 |
# File 'lib/watir-webdriver/elements/option.rb', line 29 def toggle assert_exists @element.click end |
#value ⇒ String
Returns value of value property.
374 |
# File 'lib/watir-webdriver/elements/generated.rb', line 374 attribute(String, :value, :value) |