webdriver

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package webdriver is a small W3C WebDriver client (https://www.w3.org/TR/webdriver/): just what the e2e lane for Safari needs, to drive the real Safari through safaridriver (Playwright's WebKit is not Safari). It starts the driver, creates a session, navigates and deletes the session.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Base string // http://127.0.0.1:port
	HTTP *http.Client
}

Client talks to one WebDriver server.

func Start

func Start(ctx context.Context, driver string) (c *Client, stop func(), err error)

Start runs driver (for example /usr/bin/safaridriver) on a free port and waits for GET /status to answer. stop kills the driver by PID.

func (*Client) NewSession

func (c *Client) NewSession(ctx context.Context, caps map[string]any) (*Session, error)

NewSession creates a session; caps is the alwaysMatch capabilities object.

type Error

type Error struct {
	Status  int
	Code    string // "error" field, e.g. "session not created"
	Message string
}

Error is a WebDriver error response (W3C section 6.6).

func (*Error) Error

func (e *Error) Error() string

type Session

type Session struct {
	ID string
	// Version is the browser's version the driver reported (capabilities
	// browserVersion), "" if it did not say.
	Version string
	// contains filtered or unexported fields
}

Session is one browser session.

func (*Session) Delete

func (s *Session) Delete(ctx context.Context) error

Delete ends the session.

func (*Session) Execute

func (s *Session) Execute(ctx context.Context, script string) (json.RawMessage, error)

Execute runs a script in the page and returns its JSON result.

func (*Session) Navigate

func (s *Session) Navigate(ctx context.Context, url string) error

Navigate loads url.

Jump to

Keyboard shortcuts

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