class RailsJsdom::Element
An element on the page, returned by TestHelper#find, TestHelper#all, TestHelper#first, TestHelper#find_field, TestHelper#find_button and TestHelper#find_link.
An element refers to a node in the live page. Actions on it settle the page like the TestHelper actions. Once the node leaves the page, for example after a navigation, using the element raises RailsJsdom::Error.
item = find(“#cart li”, text: “Mug”) item.find_button(“Remove”).click assert_equal “2”, find_field(“Quantity”).value
Public Instance Methods
Source
# File lib/rails_jsdom/element.rb, line 163 def ==(other) other.is_a?(Element) && other.handle == handle end
Two elements are equal when they refer to the same node.
Source
# File lib/rails_jsdom/element.rb, line 102 def [](name) name.to_s == "value" ? value : description.fetch("attributes")[name.to_s] end
The value of the attribute name, or the current value for :value.
Source
# File lib/rails_jsdom/element.rb, line 112 scoped_helper :all
Like TestHelper#all, searching inside this element.
Source
# File lib/rails_jsdom/element.rb, line 144 scoped_helper :assert_no_selector
Like TestHelper#assert_no_selector, inside this element.
Source
# File lib/rails_jsdom/element.rb, line 136 scoped_helper :assert_no_text
Like TestHelper#assert_no_text, for the text inside this element.
Source
# File lib/rails_jsdom/element.rb, line 140 scoped_helper :assert_selector
Like TestHelper#assert_selector, inside this element.
Source
# File lib/rails_jsdom/element.rb, line 132 scoped_helper :assert_text
Like TestHelper#assert_text, for the text inside this element.
Source
# File lib/rails_jsdom/element.rb, line 87 read :checked?
Whether a checkbox or radio button is checked.
Source
# File lib/rails_jsdom/element.rb, line 95 read :disabled?
Whether the element is disabled.
Source
# File lib/rails_jsdom/element.rb, line 47 action :double_click
Double-clicks the element. See TestHelper#double_click.
Source
# File lib/rails_jsdom/element.rb, line 108 scoped_helper :find
Like TestHelper#find, searching inside this element.
Source
# File lib/rails_jsdom/element.rb, line 120 scoped_helper :find_field
Like TestHelper#find_field, searching inside this element.
Source
# File lib/rails_jsdom/element.rb, line 128 scoped_helper :find_link
Like TestHelper#find_link, searching inside this element.
Source
# File lib/rails_jsdom/element.rb, line 116 scoped_helper :first
Like TestHelper#first, searching inside this element.
Source
# File lib/rails_jsdom/element.rb, line 160 scoped_helper :has_no_selector?
Like TestHelper#has_no_selector?, inside this element.
Source
# File lib/rails_jsdom/element.rb, line 152 scoped_helper :has_no_text?
Like TestHelper#has_no_text?, for the text inside this element.
Source
# File lib/rails_jsdom/element.rb, line 156 scoped_helper :has_selector?
Like TestHelper#has_selector?, inside this element.
Source
# File lib/rails_jsdom/element.rb, line 148 scoped_helper :has_text?
Like TestHelper#has_text?, for the text inside this element.
Source
# File lib/rails_jsdom/element.rb, line 43 action :hover
Moves the pointer over the element. See TestHelper#hover.
Source
# File lib/rails_jsdom/element.rb, line 51 action :right_click
Right-clicks the element. See TestHelper#right_click.
Source
# File lib/rails_jsdom/element.rb, line 55 action :select_option
Selects this option in its select.
Source
# File lib/rails_jsdom/element.rb, line 91 read :selected?
Whether an option is selected.
Source
# File lib/rails_jsdom/element.rb, line 69 def send_keys(*keys) perform(:send_keys, keys: RailsJsdom.keys(keys)) end
Focuses the element and types keys into it. See TestHelper#send_keys.
Source
# File lib/rails_jsdom/element.rb, line 64 def set(value) perform(:set, value: value) end
Sets the element’s value: text for a text-like field or a contenteditable element, true or false for a checkbox, true to select a radio button.
Source
# File lib/rails_jsdom/element.rb, line 83 read :tag_name, from: "tag"
The element’s tag name, such as "button".
Source
# File lib/rails_jsdom/element.rb, line 75 read :text
The visible text of the element.
Source
# File lib/rails_jsdom/element.rb, line 59 action :unselect_option
Deselects this option in a select that allows multiple options.
Source
# File lib/rails_jsdom/element.rb, line 79 read :value
The current value of a field, or nil for an element without one.
Source
# File lib/rails_jsdom/element.rb, line 99 read :visible?
Whether the element is visible: neither it nor an ancestor is hidden.