Class: Capybara::Driver::RackTest::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::RackTest::Node
show all
- Defined in:
- lib/capybara/driver/rack_test_driver.rb
Direct Known Subclasses
Form
Instance Attribute Summary
Attributes inherited from Node
#driver, #node
Instance Method Summary
collapse
Methods inherited from Node
#initialize, #value
Constructor Details
This class inherits a constructor from Capybara::Node
Instance Method Details
#[](name) ⇒ Object
10
11
12
13
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 10
def [](name)
value = node[name.to_s]
return value.to_s if value
end
|
#click ⇒ Object
37
38
39
40
41
42
43
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 37
def click
if tag_name == 'a'
driver.visit(self[:href])
elsif (tag_name == 'input' or tag_name == 'button') and %w(submit image).include?(type)
Form.new(driver, form).submit(self)
end
end
|
#select(option) ⇒ Object
32
33
34
35
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 32
def select(option)
node.xpath(".//option").each { |node| node.remove_attribute("selected") }
node.xpath(".//option[contains(.,'#{option}')]").first["selected"] = 'selected'
end
|
#set(value) ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 15
def set(value)
if tag_name == 'input' and %w(text password hidden file).include?(type)
node['value'] = value.to_s
elsif tag_name == 'input' and type == 'radio'
driver.html.xpath("//input[@name='#{self[:name]}']").each { |node| node.remove_attribute("checked") }
node['checked'] = 'checked'
elsif tag_name == 'input' and type == 'checkbox'
if value
node['checked'] = 'checked'
else
node.remove_attribute('checked')
end
elsif tag_name == "textarea"
node.content = value.to_s
end
end
|
#tag_name ⇒ Object
45
46
47
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 45
def tag_name
node.node_name
end
|
#text ⇒ Object
6
7
8
|
# File 'lib/capybara/driver/rack_test_driver.rb', line 6
def text
node.text
end
|