Class: Capybara::Driver::Celerity::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::Celerity::Node
show all
- Defined in:
- lib/capybara/driver/celerity_driver.rb
Instance Attribute Summary
Attributes inherited from Node
#driver, #node
Instance Method Summary
collapse
Methods inherited from Node
#initialize
Methods included from Searchable
#all, #find, #find_button, #find_by_id, #find_field, #find_link
Constructor Details
This class inherits a constructor from Capybara::Node
Instance Method Details
#[](name) ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/capybara/driver/celerity_driver.rb', line 7
def [](name)
value = if name.to_sym == :class
node.class_name
else
node.send(name.to_sym)
end
return value if value and not value.to_s.empty?
end
|
#click ⇒ Object
52
53
54
|
# File 'lib/capybara/driver/celerity_driver.rb', line 52
def click
node.click
end
|
#drag_to(element) ⇒ Object
56
57
58
59
60
|
# File 'lib/capybara/driver/celerity_driver.rb', line 56
def drag_to(element)
node.fire_event('mousedown')
element.node.fire_event('mousemove')
element.node.fire_event('mouseup')
end
|
#path ⇒ Object
72
73
74
|
# File 'lib/capybara/driver/celerity_driver.rb', line 72
def path
node.xpath
end
|
#select(option) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/capybara/driver/celerity_driver.rb', line 28
def select(option)
node.select(option)
rescue
options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
|
#set(value) ⇒ Object
24
25
26
|
# File 'lib/capybara/driver/celerity_driver.rb', line 24
def set(value)
node.set(value)
end
|
#tag_name ⇒ Object
62
63
64
65
66
|
# File 'lib/capybara/driver/celerity_driver.rb', line 62
def tag_name
node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
end
|
#text ⇒ Object
3
4
5
|
# File 'lib/capybara/driver/celerity_driver.rb', line 3
def text
node.text
end
|
#trigger(event) ⇒ Object
76
77
78
|
# File 'lib/capybara/driver/celerity_driver.rb', line 76
def trigger(event)
node.fire_event(event.to_s)
end
|
#unselect(option) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/capybara/driver/celerity_driver.rb', line 35
def unselect(option)
unless node.multiple?
raise Capybara::UnselectNotAllowed, "Cannot unselect option '#{option}' from single select box."
end
selected_options = node.selected_options
if unselect_option = selected_options.detect { |value| value == option } ||
selected_options.detect { |value| value.index(option) }
node.clear
(selected_options - [unselect_option]).each { |value| node.select_value(value) }
else
options = all(:xpath, "//option").map { |o| "'#{o.text}'" }.join(', ')
raise Capybara::OptionNotFound, "No such option '#{option}' in this select box. Available options: #{options}"
end
end
|
#value ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/capybara/driver/celerity_driver.rb', line 16
def value
if node.type == 'select-multiple'
node.selected_options
else
super
end
end
|
#visible? ⇒ Boolean
68
69
70
|
# File 'lib/capybara/driver/celerity_driver.rb', line 68
def visible?
node.visible?
end
|