class HTMLTestUtils::Wrapper
- HTMLTestUtils::Wrapper
- Reference
- Object
Defined in:
wrapper.crConstructors
Instance Method Summary
-
#attribute_by(attr_name : String) : String | Nil
Returns a
String
of the attribute specified by attr_name, ornil
if the element doesn't have the specified attribute. -
#attributes : Hash(String, String)
Returns a
Hash
containing all the element's attributes. -
#classes : Array(String)
Returns an
Array
of classes for the element, or an emptyArray
if the element has no classes. -
#exists? : Bool
Returns a
Bool
that indicates if the specified HTML exists within the parsed HTML tree. -
#find(selector : String) : Wrapper
Returns a
Wrapper
for the HTML element that matches selector. -
#find_all(selector : String) : Array(Wrapper)
Returns an
Array
ofWrapper
objects that match selector. -
#id : String | Nil
Returns the id property of the element if it has one, or
nil
if there is no id. -
#tag : String
Return the HMTL tag of the element.
-
#text : String
Returns all of the text within the element, including that of child elements.
Constructor Detail
Instance Method Detail
Returns a String
of the attribute specified by attr_name, or nil
if the
element doesn't have the specified attribute.
The element's classes can be determined this way, but they will be returned as a
single string, as opposed to #classes
, which returns them as an array.
Returns a Hash
containing all the element's attributes.
Classes are include in this Hash
, but they're returned as a single String
, not an
Array
, as #classes
does.
Returns an Array
of classes for the element, or an empty Array
if the element has
no classes.
Returns a Bool
that indicates if the specified HTML exists within the parsed HTML
tree.
Returns a Wrapper
for the HTML element that matches selector. If more than one
element matches selector, then it will return the first one it finds.
If no matching element is found, the returned Wrapper
will be empty, thus it will
return false
for #exists?
, and raise an error on any other queries.
The syntax for selector is the same that is used by standard CSS rules.
Returns an Array
of Wrapper
objects that match selector. If no matching elements
are found, an empty Wrapper
is returned.
The syntax for selector is the same that is used by standard CSS rules.
Returns the id property of the element if it has one, or nil
if there is no id.