chromedptest

package module
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2021 License: MIT Imports: 1 Imported by: 0

README

chromedp-test

a small testrunner lib for chromedp

Organize ChromeDP action as Functional Web-TestCases in TestSuites and run them.

Sample

Organize and run Tests in TestSuites
func RunTests(url string) {
	runner.Suites(url,
		runner.TestSuites{
			"1 Login Test": runner.TestSuite{
				"01-Login":        Case01Login,
			},
		},
		runner.Options{
			SortSuites: true,
			SortTests:  true,
		},
	)
}
Implement a test
func Case01Login(ctx context.Context, url string) error {
	return Run(ctx,
		group.New("preparations",
            NavigateToWebsite(url),
			group.New("regular login",
				Login(),
				WaitVisible(idEntryList, ByTestId),
			),
			group.New("logout to get to back logout page",
				Logout(),
			),
		),
		group.New("login from logout page",
			WaitVisible(idActionLogin, ByTestId),
			Click(idActionLogin, ByTestId),
			Login(),
		),
		group.New("expect to be logged in",
			WaitVisible(idEntryList, ByTestId),
			Logout(),
		),
	)
}
Scope

This library provides runner to organize and run the tests, grouping for better logging.
Writing ChromeDp Actions like NavigateToWebsite or Login is of course up to you.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Printf

func Printf(format string, a ...interface{})

func SetLogger

func SetLogger(lf LogFunc)

Types

type LogFunc

type LogFunc func(format string, a ...interface{})

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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