Class: Capybara::UI::RadioButton
- Defined in:
- lib/capybara/ui/widgets/radio_button.rb
Overview
A radio button.
Constant Summary
Constants included from Capybara::UI
Instance Attribute Summary
Attributes inherited from Widget
Class Method Summary collapse
Instance Method Summary collapse
- 
  
    
      #get  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    no button is checked. 
- 
  
    
      #id  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    The id of the checked button. 
- 
  
    
      #set(str)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    First attempts to choose the button by id or label text Then attempts to choose the button by value. 
- #to_cell ⇒ Object
- 
  
    
      #value  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    The value of the checked button. 
Methods inherited from Widget
action, #class?, #classes, #click, #double_click, filter, filter?, find_all_in, find_in, #has_action?, #hover, #html, #initialize, not_present_in?, present_in?, #right_click, selector, #text, #to_s, widget_delegator
Methods included from Widgets::DSL
Methods included from WidgetParts::Container
#has_widget?, #not_visible?, #visible?, #widget, #widgets
Methods included from Capybara::UI
Methods included from Constructors
Methods included from WidgetParts::Struct
Constructor Details
This class inherits a constructor from Capybara::UI::Widget
Class Method Details
.root(selector) ⇒ Object
| 17 18 19 | # File 'lib/capybara/ui/widgets/radio_button.rb', line 17 def self.root(selector) super(["#{selector}"]) end | 
Instance Method Details
#get ⇒ Object
no button is checked.
| 22 23 24 25 26 27 28 29 30 | # File 'lib/capybara/ui/widgets/radio_button.rb', line 22 def get if visible?(:checked_label_by_value, value) (:checked_label_by_value, value).text elsif visible?(:checked_label_by_id, id) (:checked_label_by_id, id).text else nil end end | 
#id ⇒ String
Returns The id of the checked button.
| 38 39 40 | # File 'lib/capybara/ui/widgets/radio_button.rb', line 38 def id visible?(:checked) ? (:checked).id : nil end | 
#set(str) ⇒ Object
First attempts to choose the button by id or label text Then attempts to choose the button by value
| 44 45 46 47 48 49 50 51 52 53 | # File 'lib/capybara/ui/widgets/radio_button.rb', line 44 def set(str) root.choose(str) rescue begin (:button_by_value, str).root.set(true) rescue Capybara::UI::MissingWidget => e raise InvalidRadioButton.new(e.). tap { |x| x.set_backtrace e.backtrace } end end | 
#to_cell ⇒ Object
| 59 60 61 | # File 'lib/capybara/ui/widgets/radio_button.rb', line 59 def to_cell get end |