class HTMLTestUtils::Wrapper

Defined in:

wrapper.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(node : Lexbor::Node | Nil) #

[View source]

Instance Method Detail

def attribute_by(attr_name : String) : String | Nil #

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.


[View source]
def attributes : Hash(String, String) #

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.


[View source]
def classes : Array(String) #

Returns an Array of classes for the element, or an empty Array if the element has no classes.


[View source]
def exists? : Bool #

Returns a Bool that indicates if the specified HTML exists within the parsed HTML tree.


[View source]
def find(selector : String) : Wrapper #

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.


[View source]
def find_all(selector : String) : Array(Wrapper) #

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.


[View source]
def id : String | Nil #

Returns the id property of the element if it has one, or nil if there is no id.


[View source]
def tag : String #

Return the HMTL tag of the element.


[View source]
def text : String #

Returns all of the text within the element, including that of child elements.


[View source]