webtester

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 9 Imported by: 0

README

CircleCI

web test library for golang

example:

func TestSimple(tt *testing.T) {
	t := webtester.Setup(tt, chrome.DriverPath)
	defer t.TearDown()

	d := t.OpenBrowser()
	d.SetPageLoadTimeout(4 * time.Second)

	d.VisitTo("https://tour.golang.org/welcome/1")

	d.WaitFor("id:run")
	d.MustFindElement("id:run").Click()

	d.WaitFor("class:stdout")
	d.MustFindElement("class:stdout").VerifyText(strings.Contains, "Hello")

	d.MustFindElement("class:next-page").Click()
	d.ExpectTransitTo("/welcome/2").TakeScreenshot("page2.png")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Browser

type Browser struct {
	testing.TB
	// contains filtered or unexported fields
}

func (*Browser) Element

func (b *Browser) Element() (elem *Element)

func (*Browser) Expect

func (b *Browser) Expect(target string, text string)

func (*Browser) ExpectTransitTo

func (b *Browser) ExpectTransitTo(rawurl string) *Browser

func (*Browser) GetWindowSize

func (b *Browser) GetWindowSize() (width, height int, err error)

func (*Browser) MustFindElement

func (b *Browser) MustFindElement(target string) *Element

func (*Browser) MustFindElements

func (b *Browser) MustFindElements(target string) []*Element

func (*Browser) Session

func (b *Browser) Session() (session *webdriver.Session)

func (*Browser) SetPageLoadTimeout

func (b *Browser) SetPageLoadTimeout(timeout time.Duration)

func (*Browser) SetWindowSize

func (b *Browser) SetWindowSize(width, height int)

func (*Browser) TakeScreenshot

func (b *Browser) TakeScreenshot(name string) *Browser

func (*Browser) TakeSource

func (b *Browser) TakeSource(name string) *Browser

func (*Browser) VisitTo

func (b *Browser) VisitTo(rawurl string) *Browser

func (*Browser) WaitFor

func (b *Browser) WaitFor(target string) *Browser

func (*Browser) WaitForText

func (b *Browser) WaitForText(target string, text string) *Browser

func (*Browser) WebElement

func (b *Browser) WebElement() (elem webdriver.WebElement)

type Driver

type Driver struct {
	testing.TB
	// contains filtered or unexported fields
}

func Setup

func Setup(tb testing.TB, path string) *Driver

func (*Driver) OpenBrowser

func (d *Driver) OpenBrowser() *Browser

func (*Driver) TearDown

func (d *Driver) TearDown()

type Element

type Element struct {
	testing.TB
	// contains filtered or unexported fields
}

func (*Element) Clear

func (e *Element) Clear() *Element

func (*Element) Click

func (e *Element) Click() *Element

func (*Element) Input

func (e *Element) Input(text string) *Element

func (*Element) VerifyText

func (e *Element) VerifyText(fn func(string, string) bool, expect string) *Element

func (*Element) WaitForDisabled added in v0.2.1

func (e *Element) WaitForDisabled() *Element

func (*Element) WaitForEnabled added in v0.2.1

func (e *Element) WaitForEnabled() *Element

func (*Element) WebElement

func (e *Element) WebElement() (elem webdriver.WebElement)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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