browsertest

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package browsertest provides integration test helpers for our browser-based tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoginToUpstreamGitHub added in v0.31.0

func LoginToUpstreamGitHub(t *testing.T, b *Browser, upstream testlib.TestGithubUpstream)

LoginToUpstreamGitHub expects the page to be redirected to GitHub. It knows how to enter the test username/password and submit the upstream login form.

func LoginToUpstreamLDAP added in v0.18.0

func LoginToUpstreamLDAP(t *testing.T, b *Browser, issuer, username, password string)

LoginToUpstreamLDAP expects the page to be redirected to the Supervisor's login UI for an LDAP/AD IDP. It knows how to enter the test username/password and submit the upstream login form.

func LoginToUpstreamOIDC added in v0.18.0

func LoginToUpstreamOIDC(t *testing.T, b *Browser, upstream testlib.TestOIDCUpstream)

LoginToUpstreamOIDC expects the page to be redirected to one of several known upstream IDPs. It knows how to enter the test username/password and submit the upstream login form.

func SubmitUpstreamLDAPLoginForm added in v0.18.0

func SubmitUpstreamLDAPLoginForm(t *testing.T, b *Browser, username string, password string)

func WaitForUpstreamLDAPLoginPageWithError added in v0.18.0

func WaitForUpstreamLDAPLoginPageWithError(t *testing.T, b *Browser, issuer string)

Types

type Browser added in v0.25.0

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

Browser abstracts the specific browser driver library that we use and provides an interface for integration tests to interact with the browser.

func OpenBrowser added in v0.25.0

func OpenBrowser(t *testing.T) *Browser

OpenBrowser opens a web browser as a subprocess and returns a Browser which allows further interactions with the browser. The subprocess will be cleaned up at the end of the test. Each call to OpenBrowser creates a new browser which does not share any cookies with other browsers from other calls.

func (*Browser) AttrValueOfFirstMatch added in v0.25.0

func (b *Browser) AttrValueOfFirstMatch(t *testing.T, cssSelector string, attributeName string) string

func (*Browser) ClickFirstMatch added in v0.25.0

func (b *Browser) ClickFirstMatch(t *testing.T, cssSelector string) string

func (*Browser) FindConsoleEventWithTextMatching added in v0.25.0

func (b *Browser) FindConsoleEventWithTextMatching(consoleEventAPIType string, re *regexp.Regexp) (string, bool)

FindConsoleEventWithTextMatching searches the browser's console that have been observed so far to find an event with an argument (converted to a string) that matches the provided regexp. consoleEventAPIType could be any of the console.funcName() names, e.g. "log", "info", "error", etc. It returns the first matching event argument value. It doesn't worry about optimizing the search speed because there should not be too many console events and because this just is a test helper.

func (*Browser) Navigate added in v0.25.0

func (b *Browser) Navigate(t *testing.T, url string)

func (*Browser) SendKeysToFirstMatch added in v0.25.0

func (b *Browser) SendKeysToFirstMatch(t *testing.T, cssSelector string, runesToType string)

func (*Browser) TextOfFirstMatch added in v0.25.0

func (b *Browser) TextOfFirstMatch(t *testing.T, cssSelector string) string

func (*Browser) Title added in v0.25.0

func (b *Browser) Title(t *testing.T) string

func (*Browser) WaitForURL added in v0.25.0

func (b *Browser) WaitForURL(t *testing.T, regex *regexp.Regexp)

WaitForURL expects the page to eventually navigate to a URL matching the specified pattern. It waits for this to occur and times out, failing the test, if it never does.

func (*Browser) WaitForVisibleElements added in v0.25.0

func (b *Browser) WaitForVisibleElements(t *testing.T, cssSelectors ...string)

Jump to

Keyboard shortcuts

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