Class: Capybara::Driver::Webkit::Node
- Inherits:
-
Node
- Object
- Node
- Capybara::Driver::Webkit::Node
- Defined in:
- lib/capybara/driver/webkit/node.rb
Constant Summary collapse
- NBSP =
"\xC2\xA0"
Instance Method Summary collapse
- #[](name) ⇒ Object
- #allow_unattached_nodes? ⇒ Boolean
- #attached? ⇒ Boolean
- #automatic_reload? ⇒ Boolean
- #browser ⇒ Object
- #checked? ⇒ Boolean
- #click ⇒ Object
- #disabled? ⇒ Boolean
- #drag_to(element) ⇒ Object
- #find(xpath) ⇒ Object
- #invoke(name, *args) ⇒ Object
- #multiple_select? ⇒ Boolean
- #path ⇒ Object
- #select_option ⇒ Object
- #selected? ⇒ Boolean
- #set(value) ⇒ Object
- #tag_name ⇒ Object
- #text ⇒ Object
- #trigger(event) ⇒ Object
- #unselect_option ⇒ Object
- #value ⇒ Object
- #visible? ⇒ Boolean
Instance Method Details
#[](name) ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'lib/capybara/driver/webkit/node.rb', line 10 def [](name) value = invoke("attribute", name) if name == 'checked' || name == 'disabled' value == 'true' else value end end |
#allow_unattached_nodes? ⇒ Boolean
98 99 100 |
# File 'lib/capybara/driver/webkit/node.rb', line 98 def allow_unattached_nodes? !automatic_reload? end |
#attached? ⇒ Boolean
106 107 108 |
# File 'lib/capybara/driver/webkit/node.rb', line 106 def attached? browser.command("Node", "isAttached", native) == "true" end |
#automatic_reload? ⇒ Boolean
102 103 104 |
# File 'lib/capybara/driver/webkit/node.rb', line 102 def automatic_reload? Capybara.respond_to?(:automatic_reload) && Capybara.automatic_reload end |
#browser ⇒ Object
110 111 112 |
# File 'lib/capybara/driver/webkit/node.rb', line 110 def browser driver.browser end |
#checked? ⇒ Boolean
68 69 70 |
# File 'lib/capybara/driver/webkit/node.rb', line 68 def checked? self['checked'] end |
#click ⇒ Object
48 49 50 |
# File 'lib/capybara/driver/webkit/node.rb', line 48 def click invoke "click" end |
#disabled? ⇒ Boolean
72 73 74 |
# File 'lib/capybara/driver/webkit/node.rb', line 72 def disabled? self['disabled'] end |
#drag_to(element) ⇒ Object
52 53 54 |
# File 'lib/capybara/driver/webkit/node.rb', line 52 def drag_to(element) invoke 'dragTo', element.native end |
#find(xpath) ⇒ Object
84 85 86 87 88 |
# File 'lib/capybara/driver/webkit/node.rb', line 84 def find(xpath) invoke("findWithin", xpath).split(',').map do |native| self.class.new(driver, native) end end |
#invoke(name, *args) ⇒ Object
90 91 92 93 94 95 96 |
# File 'lib/capybara/driver/webkit/node.rb', line 90 def invoke(name, *args) if allow_unattached_nodes? || attached? browser.command "Node", name, native, *args else raise Capybara::Driver::Webkit::NodeNotAttachedError end end |
#multiple_select? ⇒ Boolean
114 115 116 |
# File 'lib/capybara/driver/webkit/node.rb', line 114 def multiple_select? self.tag_name == "select" && self["multiple"] == "multiple" end |
#path ⇒ Object
76 77 78 |
# File 'lib/capybara/driver/webkit/node.rb', line 76 def path raise Capybara::NotSupportedByDriverError end |
#select_option ⇒ Object
35 36 37 |
# File 'lib/capybara/driver/webkit/node.rb', line 35 def select_option invoke "selectOption" end |
#selected? ⇒ Boolean
64 65 66 |
# File 'lib/capybara/driver/webkit/node.rb', line 64 def selected? invoke("selected") == "true" end |
#set(value) ⇒ Object
31 32 33 |
# File 'lib/capybara/driver/webkit/node.rb', line 31 def set(value) invoke "set", value end |
#tag_name ⇒ Object
56 57 58 |
# File 'lib/capybara/driver/webkit/node.rb', line 56 def tag_name invoke "tagName" end |
#text ⇒ Object
6 7 8 |
# File 'lib/capybara/driver/webkit/node.rb', line 6 def text invoke("text").gsub(NBSP, ' ').gsub(/\s+/u, ' ').strip end |
#trigger(event) ⇒ Object
80 81 82 |
# File 'lib/capybara/driver/webkit/node.rb', line 80 def trigger(event) invoke "trigger", event end |
#unselect_option ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/capybara/driver/webkit/node.rb', line 39 def unselect_option select = find("ancestor::select").first if select.multiple_select? invoke "unselectOption" else raise Capybara::UnselectNotAllowed end end |
#value ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/capybara/driver/webkit/node.rb', line 19 def value if multiple_select? self.find(".//option").select do |option| option["selected"] == "selected" end.map do |option| option.value end else invoke "value" end end |
#visible? ⇒ Boolean
60 61 62 |
# File 'lib/capybara/driver/webkit/node.rb', line 60 def visible? invoke("visible") == "true" end |