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, #native
Instance Method Summary
collapse
Methods inherited from Node
#initialize, #inspect
Instance Method Details
#[](name) ⇒ Object
7
8
9
10
|
# File 'lib/capybara/driver/celerity_driver.rb', line 7
def [](name)
value = native.attribute_value(name.to_sym)
return value if value and not value.to_s.empty?
end
|
#checked? ⇒ Boolean
59
60
61
62
63
|
# File 'lib/capybara/driver/celerity_driver.rb', line 59
def checked?
native.checked?
rescue false
end
|
#click ⇒ Object
39
40
41
|
# File 'lib/capybara/driver/celerity_driver.rb', line 39
def click
native.click
end
|
#drag_to(element) ⇒ Object
43
44
45
46
47
|
# File 'lib/capybara/driver/celerity_driver.rb', line 43
def drag_to(element)
native.fire_event('mousedown')
element.native.fire_event('mousemove')
element.native.fire_event('mouseup')
end
|
#find(locator) ⇒ Object
79
80
81
82
83
|
# File 'lib/capybara/driver/celerity_driver.rb', line 79
def find(locator)
noko_node = Nokogiri::HTML(driver.body).xpath(native.xpath).first
all_nodes = noko_node.xpath(locator).map { |n| n.path }.join(' | ')
if all_nodes.empty? then [] else driver.find(all_nodes) end
end
|
#path ⇒ Object
71
72
73
|
# File 'lib/capybara/driver/celerity_driver.rb', line 71
def path
native.xpath
end
|
#select_option ⇒ Object
24
25
26
|
# File 'lib/capybara/driver/celerity_driver.rb', line 24
def select_option
native.click
end
|
#selected? ⇒ Boolean
65
66
67
68
69
|
# File 'lib/capybara/driver/celerity_driver.rb', line 65
def selected?
native.selected?
rescue false
end
|
#set(value) ⇒ Object
20
21
22
|
# File 'lib/capybara/driver/celerity_driver.rb', line 20
def set(value)
native.set(value)
end
|
#tag_name ⇒ Object
49
50
51
52
53
|
# File 'lib/capybara/driver/celerity_driver.rb', line 49
def tag_name
native.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
end
|
#text ⇒ Object
3
4
5
|
# File 'lib/capybara/driver/celerity_driver.rb', line 3
def text
native.text
end
|
#trigger(event) ⇒ Object
75
76
77
|
# File 'lib/capybara/driver/celerity_driver.rb', line 75
def trigger(event)
native.fire_event(event.to_s)
end
|
#unselect_option ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/capybara/driver/celerity_driver.rb', line 28
def unselect_option
unless select_node.native.multiple?
raise Capybara::UnselectNotAllowed, "Cannot unselect option from single select box."
end
selected_nodes = select_node.find('.//option[@selected]')
select_node.native.clear
selected_nodes.each { |n| n.click unless n.path == path }
end
|
#value ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/capybara/driver/celerity_driver.rb', line 12
def value
if tag_name == "select" and native.multiple?
find(".//option[@selected]").map { |n| if n.has_value? then n.value else n.text end }
else
native.value
end
end
|
#visible? ⇒ Boolean
55
56
57
|
# File 'lib/capybara/driver/celerity_driver.rb', line 55
def visible?
native.visible?
end
|