htmltest

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 9 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 GetTestingT added in v0.11.0

func GetTestingT(w html.Window) (testing.TB, bool)

func SetTestingT added in v0.11.0

func SetTestingT(w html.Window, val testing.TB)

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) NewWindow added in v0.10.3

func (b BrowserHelper) NewWindow() WindowHelper

func (BrowserHelper) OpenWindow

func (b BrowserHelper) OpenWindow(url string) WindowHelper

type Evaler added in v0.11.0

type Evaler interface {
	Eval(string) (any, error)
}

Evaler is the interface for the single method Eval that executes JavaScript and returns the evaluated value.

type HTMLDocumentHelper

type HTMLDocumentHelper struct {
	HTMLParentNodeHelper
	html.HTMLDocument
	// 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 html.HTMLDocument) 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) MustQuerySelectorHTML added in v0.11.0

func (h HTMLParentNodeHelper) MustQuerySelectorHTML(pattern string) HTMLElementHelper

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 JsAssert added in v0.11.0

type JsAssert struct {
	// contains filtered or unexported fields
}

JsAssert helps write tests for the state of values in the JavaScript realm.

func (JsAssert) False added in v0.11.0

func (a JsAssert) False(expr string)

func (JsAssert) InstanceOf added in v0.11.0

func (a JsAssert) InstanceOf(target, expected string)

Verifies that the target object is an instance of the expected class. Both target and expected must be valid identifiers in global JavaScript scope.

func (JsAssert) True added in v0.11.0

func (a JsAssert) True(expr string)

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 NewWindowHTML added in v0.9.0

func NewWindowHTML(t testing.TB, s string) WindowHelper

func NewWindowHelper

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

func (WindowHelper) Assert added in v0.11.0

func (h WindowHelper) Assert() JsAssert

Return a JsAssert value that can be used to verify the state of JavaScript values.

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