Class: Capybara::Simulated::Node
- Inherits:
-
Driver::Node
- Object
- Driver::Node
- Capybara::Simulated::Node
- Includes:
- Node::WhitespaceNormalizer
- Defined in:
- lib/capybara/simulated/node.rb
Instance Method Summary collapse
- #==(other) ⇒ Object
- #[](name) ⇒ Object
- #all_text ⇒ Object
- #checked? ⇒ Boolean
- #click(keys = [], **opts) ⇒ Object
- #disabled? ⇒ Boolean
- #double_click(keys = [], **opts) ⇒ Object
- #drag_to(other, **_opts) ⇒ Object
- #drop(*args) ⇒ Object
- #find_css(css) ⇒ Object
- #find_xpath(xpath) ⇒ Object
- #handle_id ⇒ Object
- #hover ⇒ Object
- #inspect ⇒ Object
- #multiple? ⇒ Boolean
- #obscured? ⇒ Boolean
- #path ⇒ Object
- #readonly? ⇒ Boolean
- #rect ⇒ Object
- #right_click(keys = [], **opts) ⇒ Object
- #scroll_by(_x, _y) ⇒ Object
- #scroll_to(_element, _alignment, _position = nil) ⇒ Object
- #select_option ⇒ Object
- #selected? ⇒ Boolean
- #send_keys(*keys) ⇒ Object
- #set(value, **_opts) ⇒ Object
- #shadow_root ⇒ Object
- #style(_styles) ⇒ Object
- #submit ⇒ Object
- #tag_name ⇒ Object
- #trigger(event) ⇒ Object
- #unselect_option ⇒ Object
- #value ⇒ Object
- #visible? ⇒ Boolean
- #visible_text ⇒ Object
Instance Method Details
#==(other) ⇒ Object
185 186 187 |
# File 'lib/capybara/simulated/node.rb', line 185 def ==(other) other.is_a?(Node) && other.handle_id == handle_id end |
#[](name) ⇒ Object
19 20 21 22 23 24 25 26 |
# File 'lib/capybara/simulated/node.rb', line 19 def [](name) case name.to_s when 'value' then value when 'checked' then checked? ? 'true' : nil when 'selected' then selected? ? 'true' : nil else browser.attr(handle_id, name) end end |
#all_text ⇒ Object
11 12 13 |
# File 'lib/capybara/simulated/node.rb', line 11 def all_text normalize_spacing(browser.all_text(handle_id)) end |
#checked? ⇒ Boolean
63 64 65 |
# File 'lib/capybara/simulated/node.rb', line 63 def checked? browser.checked?(handle_id) end |
#click(keys = [], **opts) ⇒ Object
83 84 85 |
# File 'lib/capybara/simulated/node.rb', line 83 def click(keys = [], **opts) browser.click(handle_id, (keys, opts)) end |
#disabled? ⇒ Boolean
71 72 73 |
# File 'lib/capybara/simulated/node.rb', line 71 def disabled? browser.disabled?(handle_id) end |
#double_click(keys = [], **opts) ⇒ Object
91 92 93 |
# File 'lib/capybara/simulated/node.rb', line 91 def double_click(keys = [], **opts) browser.double_click(handle_id, (keys, opts)) end |
#drag_to(other, **_opts) ⇒ Object
140 141 142 143 144 145 146 |
# File 'lib/capybara/simulated/node.rb', line 140 def drag_to(other, **_opts) browser.trigger(handle_id, 'dragstart') browser.trigger(other.handle_id, 'dragenter') browser.trigger(other.handle_id, 'dragover') browser.trigger(other.handle_id, 'drop') browser.trigger(handle_id, 'dragend') end |
#drop(*args) ⇒ Object
148 149 150 151 |
# File 'lib/capybara/simulated/node.rb', line 148 def drop(*args) items = args.flat_map {|arg| drop_items_for(arg) } browser.drop(handle_id, items) end |
#find_css(css) ⇒ Object
164 165 166 |
# File 'lib/capybara/simulated/node.rb', line 164 def find_css(css) browser.find_css(css, handle_id).map {|id| self.class.new(driver, id) } end |
#find_xpath(xpath) ⇒ Object
160 161 162 |
# File 'lib/capybara/simulated/node.rb', line 160 def find_xpath(xpath) browser.find_xpath(xpath, handle_id).map {|id| self.class.new(driver, id) } end |
#handle_id ⇒ Object
9 |
# File 'lib/capybara/simulated/node.rb', line 9 def handle_id = native |
#hover ⇒ Object
128 129 130 |
# File 'lib/capybara/simulated/node.rb', line 128 def hover browser.hover(handle_id) end |
#inspect ⇒ Object
189 190 191 192 193 |
# File 'lib/capybara/simulated/node.rb', line 189 def inspect %(#<Capybara::Simulated::Node tag="#{tag_name}" id=#{handle_id}>) rescue StandardError super end |
#multiple? ⇒ Boolean
79 80 81 |
# File 'lib/capybara/simulated/node.rb', line 79 def multiple? browser.multiple?(handle_id) end |
#obscured? ⇒ Boolean
59 60 61 |
# File 'lib/capybara/simulated/node.rb', line 59 def obscured? false end |
#path ⇒ Object
172 173 174 |
# File 'lib/capybara/simulated/node.rb', line 172 def path browser.path(handle_id) end |
#readonly? ⇒ Boolean
75 76 77 |
# File 'lib/capybara/simulated/node.rb', line 75 def readonly? browser.readonly?(handle_id) end |
#rect ⇒ Object
168 169 170 |
# File 'lib/capybara/simulated/node.rb', line 168 def rect browser.rect(handle_id) end |
#right_click(keys = [], **opts) ⇒ Object
87 88 89 |
# File 'lib/capybara/simulated/node.rb', line 87 def right_click(keys = [], **opts) browser.right_click(handle_id, (keys, opts)) end |
#scroll_by(_x, _y) ⇒ Object
153 |
# File 'lib/capybara/simulated/node.rb', line 153 def scroll_by(_x, _y); end |
#scroll_to(_element, _alignment, _position = nil) ⇒ Object
154 |
# File 'lib/capybara/simulated/node.rb', line 154 def scroll_to(_element, _alignment, _position = nil); end |
#select_option ⇒ Object
41 42 43 44 |
# File 'lib/capybara/simulated/node.rb', line 41 def select_option return if disabled? browser.select_option(handle_id) end |
#selected? ⇒ Boolean
67 68 69 |
# File 'lib/capybara/simulated/node.rb', line 67 def selected? browser.selected?(handle_id) end |
#send_keys(*keys) ⇒ Object
136 137 138 |
# File 'lib/capybara/simulated/node.rb', line 136 def send_keys(*keys) browser.send_keys(handle_id, keys) end |
#set(value, **_opts) ⇒ Object
32 33 34 35 36 37 38 39 |
# File 'lib/capybara/simulated/node.rb', line 32 def set(value, **_opts) return if disabled? # readonly is meaningless on checkbox/radio; the HTML spec ignores # it for those types, and Capybara's specs explicitly assert that. type = (self[:type] || tag_name || '').to_s.downcase return if readonly? && type != 'checkbox' && type != 'radio' browser.set_value(handle_id, value) end |
#shadow_root ⇒ Object
176 177 178 179 |
# File 'lib/capybara/simulated/node.rb', line 176 def shadow_root id = browser.shadow_root(handle_id) id ? Node.new(driver, id) : nil end |
#style(_styles) ⇒ Object
181 182 183 |
# File 'lib/capybara/simulated/node.rb', line 181 def style(_styles) raise NotImplementedError, 'The simulated driver does not process CSS' end |
#submit ⇒ Object
156 157 158 |
# File 'lib/capybara/simulated/node.rb', line 156 def submit browser.submit(handle_id) end |
#tag_name ⇒ Object
51 52 53 |
# File 'lib/capybara/simulated/node.rb', line 51 def tag_name browser.tag_name(handle_id) end |
#trigger(event) ⇒ Object
132 133 134 |
# File 'lib/capybara/simulated/node.rb', line 132 def trigger(event) browser.trigger(handle_id, event) end |
#unselect_option ⇒ Object
46 47 48 49 |
# File 'lib/capybara/simulated/node.rb', line 46 def unselect_option raise Capybara::UnselectNotAllowed, 'Cannot unselect option from single select box.' unless select_node_multiple? browser.unselect_option(handle_id) end |
#value ⇒ Object
28 29 30 |
# File 'lib/capybara/simulated/node.rb', line 28 def value browser.value(handle_id) end |
#visible? ⇒ Boolean
55 56 57 |
# File 'lib/capybara/simulated/node.rb', line 55 def visible? browser.visible?(handle_id) end |
#visible_text ⇒ Object
15 16 17 |
# File 'lib/capybara/simulated/node.rb', line 15 def visible_text normalize_visible_spacing(browser.visible_text(handle_id)) end |