Documentation
¶
Overview ¶
Package chrome drives a headless Chrome over the DevTools protocol, for the tests of live pages: open pages, click, type, press keys and evaluate JavaScript. It is a small hand-written client over the WebSocket library the framework already uses.
Index ¶
- Variables
- func Find() string
- type Browser
- type Page
- func (p *Page) Click(sel string)
- func (p *Page) ClickElement(expr string)
- func (p *Page) Drop()
- func (p *Page) Eval(js string, out any) error
- func (p *Page) Press(key string)
- func (p *Page) Screenshot(path string)
- func (p *Page) Text(sel string) string
- func (p *Page) Type(sel, text string)
- func (p *Page) Viewport(width, height int, dark bool)
- func (p *Page) Wait(js string)
- func (p *Page) WaitText(sel, want string)
- func (p *Page) Wire() Wire
- type Wire
Constants ¶
This section is empty.
Variables ¶
var Timeout = 10 * time.Second
Timeout bounds every call and wait.
Functions ¶
Types ¶
type Browser ¶
type Browser struct {
// contains filtered or unexported fields
}
Browser is a running headless Chrome.
func Launch ¶
Launch starts Chrome for the test, closed when it ends; it skips the test when there is no Chrome (fails it under CI).
func (*Browser) Load ¶ added in v0.11.0
Load opens url in a new tab and waits for it to load: a page without Vuka's runtime (a login form, a single-page app).
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
Page is a tab.
func (*Page) ClickElement ¶ added in v0.9.0
ClickElement clicks the middle of the element a JavaScript expression finds (waiting for it) with the mouse: one in a shadow root, say.
func (*Page) Drop ¶ added in v0.3.0
func (p *Page) Drop()
Drop closes the page's WebSockets from the page's side, as a lost connection does.
func (*Page) Eval ¶
Eval evaluates a JavaScript expression (awaiting a promise) and decodes its value into out, when not nil.
func (*Page) Screenshot ¶ added in v0.9.0
Screenshot saves a PNG of the page's viewport at path.
func (*Page) Viewport ¶ added in v0.9.0
Viewport sets the page's size in CSS pixels, and whether it prefers a dark color scheme.