webdriver

package
v0.0.0-...-06c1dd3 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNoSuchElement

func IsNoSuchElement(err error) bool

Types

type Client

type Client struct {
	Endpoint string
	Client   *http.Client
}

func (*Client) Session

func (c *Client) Session(ctx context.Context) (s *session, err error)

func (*Client) SessionWithCapabilities

func (c *Client) SessionWithCapabilities(ctx context.Context, body io.Reader) (s *session, err error)

func (*Client) Status

func (c *Client) Status(ctx context.Context) error

type Element

type Element interface {
	GetElementAttribute(ctx context.Context, attribute string) (value string, err error)
	GetElementProperty(ctx context.Context, property string) (value string, err error)
	GetElementText(ctx context.Context) (text string, err error)
	Click(ctx context.Context) error
	SendKeys(ctx context.Context, keys string) error
	MoveTo(ctx context.Context) error
}

type Error

type Error struct {
	ErrorCode  ErrorCode
	Message    string
	StackTrace []string
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode string
var (
	ElementClickIntercepted ErrorCode = "element click intercepted"
	ElementNotInteractable  ErrorCode = "element not interactable"
	InsecureCertificate     ErrorCode = "insecure certificate"
	InvalidArgument         ErrorCode = "invalid argument"
	InvalidCookieDomain     ErrorCode = "invalid cookie domain"
	InvalidElementState     ErrorCode = "invalid element state"
	InvalidSelector         ErrorCode = "invalid selector"
	InvalidSessionID        ErrorCode = "invalid session id"
	JavascriptError         ErrorCode = "javascript error"
	MoveTargetOutOfBounds   ErrorCode = "move target out of bounds"
	NoSuchAlert             ErrorCode = "no such alert"
	NoSuchCookie            ErrorCode = "no such cookie"
	NoSuchElement           ErrorCode = "no such element"
	NoSuchFrame             ErrorCode = "no such frame"
	NoSuchWindow            ErrorCode = "no such window"
	ScriptTimeout           ErrorCode = "script timeout"
	SessionNotCreated       ErrorCode = "session not created"
	StaleElementReference   ErrorCode = "stale element reference"
	Timeout                 ErrorCode = "timeout"
	UnableToSetCookie       ErrorCode = "unable to set cookie"
	UnableToCaptureScreen   ErrorCode = "unable to capture screen"
	UnexpectedAlertOpen     ErrorCode = "unexpected alert open"
	UnknownCommand          ErrorCode = "unknown command"
	UnknownError            ErrorCode = "unknown error"
	UnknownMethod           ErrorCode = "unknown method"
	UnsupportedOperation    ErrorCode = "unsupported operation"
)

type FirefoxSession

type FirefoxSession interface {
	Session
	GetContext(ctx context.Context) (value string, err error)
	SetContext(ctx context.Context, value string) error
	InstallAddon(ctx context.Context, path string) (id string, err error)
	UninstallAddon(ctx context.Context, id string) error
}

type LocationStrategy

type LocationStrategy string
const (
	CSSSelector             LocationStrategy = "css selector"
	LinkTextSelector        LocationStrategy = "link text"
	PartialLinkTextSelector LocationStrategy = "partial link text"
	TagName                 LocationStrategy = "tag name"
	XPathSelector           LocationStrategy = "xpath"
)

type Session

type Session interface {
	Close(ctx context.Context) error
	NavigateTo(ctx context.Context, url string) error
	GetCurrentURL(ctx context.Context) (url string, err error)
	Back(ctx context.Context) error
	Forward(ctx context.Context) error
	Refresh(ctx context.Context) error
	GetTitle(ctx context.Context) (title string, err error)
	GetWindowHandle(ctx context.Context) (handle string, err error)
	CloseWindow(ctx context.Context) error
	SwitchToWindow(ctx context.Context, handle string) error
	GetWindowHandles(ctx context.Context) (handles []string, err error)
	NewWindow(ctx context.Context) (handle, typ string, err error)
	SwitchToParentFrame(ctx context.Context) error
	GetWindowRect(ctx context.Context) (rectangle image.Rectangle, err error)
	SetWindowRect(ctx context.Context, rectangle image.Rectangle) error
	MaximizeWindow(ctx context.Context) error
	MinimizeWindow(ctx context.Context) error
	FindElement(ctx context.Context, strategy LocationStrategy, selector string) (element Element, err error)
	FindElements(ctx context.Context, strategy LocationStrategy, selector string) (elements []Element, err error)
	Screenshot(ctx context.Context) (image image.Image, err error)
	Source(ctx context.Context) (source string, err error)
	Actions(ctx context.Context, actions io.Reader) error
	AcceptAlert(ctx context.Context) error
}

func ReconstructSession

func ReconstructSession(endpoint, sessionID string, client *http.Client) Session

Jump to

Keyboard shortcuts

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