browser

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package browser provides helpers for writing integration tests that interact with the browser. It wraps chromedp to create a real browser, click buttons, and assert results.

This package should only be used by tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cookies

func Cookies(dst *[]*http.Cookie) chromedp.Action

Cookies sets the current list of cookies into the provided destination.

func New

func New(tb testing.TB) context.Context

New creates a new headless browser context. See NewFromOptions for usage.

func NewFromOptions

func NewFromOptions(tb testing.TB, opts []chromedp.ExecAllocatorOption) context.Context

NewFromOptions creates a new browser instance. All future calls to `Run` must use the context returned by this function!

If this function returns successfully, a browser is running and ready to be used. It's recommended that you wrap the returned context in a timeout.

func NewHeadful

func NewHeadful(tb testing.TB) context.Context

NewHeadful creates a new browser context so you can actually watch the test. This is for local debugging and will fail on CI where a browser isn't actually available.

func Screenshot

func Screenshot(dst *[]byte) chromedp.Action

Screenshot captures a screenshot of the browser page in its current state. This is useful for debugging a test failure. The dst will contain the screenshot bytes in PNG format when the runner finishes.

func SetCookie

func SetCookie(c *http.Cookie) chromedp.Action

SetCookie sets a cookie with the provided parameters. This can be used to bypass login and force a specific user be logged in during the test.

Types

This section is empty.

Jump to

Keyboard shortcuts

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