htmltest

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package htmltest contains test helpers when working with the html package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnwrapHTMLElement added in v0.8.0

func UnwrapHTMLElement[T html.HTMLElement](h HTMLElementHelper) (res T)

Types

type BrowserHelper

type BrowserHelper struct {
	*browser.Browser
	// contains filtered or unexported fields
}

func NewBrowserHelper

func NewBrowserHelper(t testing.TB, b *browser.Browser) BrowserHelper

func (BrowserHelper) OpenWindow

func (b BrowserHelper) OpenWindow(url string) WindowHelper

type HTMLDocumentHelper

type HTMLDocumentHelper struct {
	HTMLParentNodeHelper
	dom.Document
	// contains filtered or unexported fields
}

Helper type on top of html.HTMLDocument to provide useful helper functions for testing.

func NewHTMLDocumentHelper

func NewHTMLDocumentHelper(t testing.TB, doc dom.Document) HTMLDocumentHelper

func ParseHTMLDocument added in v0.8.0

func ParseHTMLDocument(t testing.TB, s string) HTMLDocumentHelper

func (HTMLDocumentHelper) CreateHTMLElement

func (h HTMLDocumentHelper) CreateHTMLElement(tag string) HTMLElementHelper

func (HTMLDocumentHelper) GetHTMLElementById

func (h HTMLDocumentHelper) GetHTMLElementById(id string) html.HTMLElement

GetHTMLElementById works as html/HTMLDocument.GetElementById but assumes the found element to be an html/HTMLElement

type HTMLElementHelper

type HTMLElementHelper struct {
	html.HTMLElement
	HTMLParentNodeHelper
	// contains filtered or unexported fields
}

func NewHTMLElementHelper

func NewHTMLElementHelper(t testing.TB, e html.HTMLElement) HTMLElementHelper

func (*HTMLElementHelper) AttributeValue

func (h *HTMLElementHelper) AttributeValue(key string) string

type HTMLHelper

type HTMLHelper struct {
	T testing.TB
}

func (HTMLHelper) CreateHTMLElement

func (h HTMLHelper) CreateHTMLElement(tagname string) HTMLElementHelper

Create a single HTMLElement for testing element behaviour.

func (HTMLHelper) NewDocument

func (h HTMLHelper) NewDocument() HTMLDocumentHelper

type HTMLParentNodeHelper added in v0.8.0

type HTMLParentNodeHelper struct {
	ElementParent dom.ElementParent
	// contains filtered or unexported fields
}

func NewHTMLParentNodeHelper added in v0.8.0

func NewHTMLParentNodeHelper(t testing.TB, n dom.ElementParent) HTMLParentNodeHelper

func (HTMLParentNodeHelper) QuerySelectorHTML added in v0.8.0

func (h HTMLParentNodeHelper) QuerySelectorHTML(pattern string) (res HTMLElementHelper)

func (HTMLParentNodeHelper) QuerySelectorHTMLOpt added in v0.8.0

func (h HTMLParentNodeHelper) QuerySelectorHTMLOpt(pattern string) (res *HTMLElementHelper)

type WindowHelper

type WindowHelper struct {
	html.Window
	// contains filtered or unexported fields
}

Helper type on top of html.HTMLDocument to provide useful helper functions for testing.

func NewWindowHelper

func NewWindowHelper(t testing.TB, win html.Window) WindowHelper

func (WindowHelper) HTMLDocument

func (win WindowHelper) HTMLDocument() HTMLDocumentHelper

func (WindowHelper) MustEval added in v0.6.0

func (win WindowHelper) MustEval(script string) any

func (WindowHelper) MustLoadHTML added in v0.5.4

func (h WindowHelper) MustLoadHTML(html string)

func (WindowHelper) MustRun added in v0.6.0

func (win WindowHelper) MustRun(script string)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL