Documentation
¶
Overview ¶
Package testutil provides shared test helpers for HTML parsing and assertions.
Index ¶
- func FindAllElements(n *html.Node, match func(*html.Node) bool) []*html.Node
- func FindElement(n *html.Node, match func(*html.Node) bool) *html.Node
- func FindElementByClass(n *html.Node, class string) *html.Node
- func FindElementByID(n *html.Node, id string) *html.Node
- func FindElementByTag(n *html.Node, tag string) *html.Node
- func GetAttr(n *html.Node, key string) string
- func GetTextContent(n *html.Node) string
- func IsDescendant(ancestor, descendant *html.Node) bool
- func ParseHTML(r io.Reader) (*html.Node, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindAllElements ¶
FindAllElements returns all nodes matching the predicate.
func FindElement ¶
FindElement traverses the tree and returns the first node matching the predicate.
func FindElementByClass ¶
FindElementByClass finds the first element containing the given class.
func FindElementByID ¶
FindElementByID finds an element by its id attribute.
func FindElementByTag ¶
FindElementByTag finds the first element with the given tag name.
func GetTextContent ¶
GetTextContent returns all text content within a node.
func IsDescendant ¶ added in v0.5.0
IsDescendant reports whether descendant is a descendant of ancestor by walking ancestor's subtree. It returns false if either node is nil.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.