Class: Wrapybara::RadioButton

Inherits:
Object
  • Object
show all
Includes:
Element
Defined in:
lib/wrapybara/elements/radio_button.rb

Instance Method Summary collapse

Methods included from Element

#click, #default_how, #default_scope, #disabled?, #element, #element_identifier, #enabled?, #exists?, #focused?, #get_element, #parent_identifier, #path, #should_be_disabled, #should_be_enabled, #should_be_focused, #should_be_visible, #should_have_attribute, #should_not_be_disabled, #should_not_be_enabled, #should_not_be_focused, #should_not_be_visible, #should_not_have_attribute, #style, #visible?, #within

Constructor Details

#initialize(identifier, scope = default_scope, how = default_how) ⇒ RadioButton

Returns a new instance of RadioButton.



5
6
7
8
9
10
11
# File 'lib/wrapybara/elements/radio_button.rb', line 5

def initialize(identifier, scope = default_scope, how = default_how)
	@identifier = identifier
	@how = how
	@scope = scope
	xpath = XPath::HTML.radio_button(identifier)
	@element = get_element(xpath, scope)
end

Instance Method Details

#checkObject



27
28
29
# File 'lib/wrapybara/elements/radio_button.rb', line 27

def check
	self.set(true)
end

#checked?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/wrapybara/elements/radio_button.rb', line 35

def checked?
	self.should_exist
	# Capybara method
	@element.checked?
end

#set(state) ⇒ Object



21
22
23
24
25
# File 'lib/wrapybara/elements/radio_button.rb', line 21

def set(state)
	self.should_exist
	# Capybara method
	@element.set(state)
end

#should_be_checkedObject

Raises:



41
42
43
# File 'lib/wrapybara/elements/radio_button.rb', line 41

def should_be_checked
	raise UnmetExpectation, "Expected a radio button #{self.element_identifier} to be checked" unless self.checked?
end

#should_existObject



13
14
15
# File 'lib/wrapybara/elements/radio_button.rb', line 13

def should_exist
	super "Expected a radio button #{self.element_identifier} to exist"
end

#should_not_be_checkedObject

Raises:



45
46
47
# File 'lib/wrapybara/elements/radio_button.rb', line 45

def should_not_be_checked
	raise UnmetExpectation, "Did not expect a radio button #{self.element_identifier} to be checked" if self.checked?
end

#should_not_existObject



17
18
19
# File 'lib/wrapybara/elements/radio_button.rb', line 17

def should_not_exist
	super "Did not expect a radio button #{self.element_identifier}' to exist"
end

#uncheckObject



31
32
33
# File 'lib/wrapybara/elements/radio_button.rb', line 31

def uncheck
	self.set(false)
end