webdriver

package
v0.0.0-...-6cea00e Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package webdriver implements a client for the Selenium WebDriver wire protocol. It can be used with the ChromeDriver server and perhaps with the Selenium server.

This package implements the wire protocol described at http://code.google.com/p/selenium/wiki/JsonWireProtocol.

For Selenium, see http://code.google.com/p/selenium/. For ChromeDriver, see http://code.google.com/p/chromedriver/.

There is an ongoing W3C standardization effort for WebDriver at https://dvcs.w3.org/hg/webdriver/raw-file/tip/webdriver-spec.html. This package may or may not implement that protocol, depending on how close it is to the one linked above.

INCOMPLETE AND UNDOCUMENTED.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	Browser      string `json:"browserName,omitempty"`
	Version      string `json:"version,omitempty"`
	Platform     string `json:"platform,omitempty"`
	Javascript   bool   `json:"javascriptEnabled,omitempty"`
	Screenshot   bool   `json:"takesScreenshot,omitempty"`
	Alert        bool   `json:"handlesAlerts,omitempty"`
	Database     bool   `json:"databaseEnabled,omitempty"`
	Location     bool   `json:"locationContextEnabled,omitempty"`
	AppCache     bool   `json:"applicationCacheEnabled,omitempty"`
	Connectivity bool   `json:"browserConnectionEnabled,omitempty"`
	CSSSelectors bool   `json:"cssSelectorsEnabled,omitempty"`
	WebStorage   bool   `json:"webStorageEnabled,omitempty"`
	Rotate       bool   `json:"rotatable,omitempty"`
	InsecureSSL  bool   `json:"acceptSslCerts,omitempty"`
	NativeEvents bool   `json:"nativeEvents,omitempty"`
}

type Conn

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

func Dial

func Dial(addr string) (*Conn, error)

func (*Conn) NewSession

func (c *Conn) NewSession(cap *Capabilities) (*Session, error)

func (*Conn) Sessions

func (c *Conn) Sessions() ([]*Session, error)

func (*Conn) Status

func (c *Conn) Status() (*Status, error)
type Cookie struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Path   string `json:"path,omitempty"`
	Domain string `json:"domain,omitempty"`
	Secure bool   `json:"secure,omitempty"`
	Expiry int64  `json:"expiry,omitempty"` // Unix seconds
}

type Element

type Element struct {
	ID string `json:"ELEMENT"`
	// contains filtered or unexported fields
}

func (*Element) Attr

func (e *Element) Attr(name string) (string, bool, error)

func (*Element) CSS

func (e *Element) CSS(property string) (string, error)

func (*Element) Clear

func (e *Element) Clear() error

func (*Element) Click

func (e *Element) Click() error

func (*Element) Displayed

func (e *Element) Displayed() (bool, error)

func (*Element) Element

func (e *Element) Element(by Strategy, desc string) (*Element, error)

func (*Element) Elements

func (e *Element) Elements(by Strategy, desc string) ([]*Element, error)

func (*Element) Enabled

func (e *Element) Enabled() (bool, error)

func (*Element) Equal

func (e *Element) Equal(other *Element) (bool, error)

func (*Element) Location

func (e *Element) Location() (x, y int, err error)

func (*Element) Name

func (e *Element) Name() (string, error)

func (*Element) Selected

func (e *Element) Selected() (bool, error)

func (*Element) Size

func (e *Element) Size() (x, y int, err error)

func (*Element) Submit

func (e *Element) Submit() error

func (*Element) Text

func (e *Element) Text() (string, error)

func (*Element) Value

func (e *Element) Value(str string) error

type Error

type Error struct {
	ErrorCode ErrorCode
	Failure   Failure
}

func (*Error) Error

func (e *Error) Error() string

type ErrorCode

type ErrorCode int
const (
	Success                    ErrorCode = 0
	NoSuchDriver               ErrorCode = 6
	NoSuchElement              ErrorCode = 7
	NoSuchFrame                ErrorCode = 8
	UnknownCommand             ErrorCode = 9
	StaleElementReference      ErrorCode = 10
	ElementNotVisible          ErrorCode = 11
	InvalidElementState        ErrorCode = 12
	UnknownError               ErrorCode = 13
	ElementIsNotSelectable     ErrorCode = 15
	JavaScriptError            ErrorCode = 17
	XPathLookupError           ErrorCode = 19
	TimeoutError               ErrorCode = 21
	NoSuchWindow               ErrorCode = 23
	InvalidCookieDomain        ErrorCode = 24
	UnableToSetCookie          ErrorCode = 25
	UnexpectedAlertOpen        ErrorCode = 26
	NoAlertOpenError           ErrorCode = 27
	ScriptTimeoutError         ErrorCode = 28
	InvalidElementCoordinates  ErrorCode = 29
	IMENotAvailable            ErrorCode = 30
	IMEEngineActivationFailed  ErrorCode = 31
	InvalidSelector            ErrorCode = 32
	SessionNotCreatedException ErrorCode = 33
	MoveTargetOutOfBounds      ErrorCode = 34
)

func (ErrorCode) String

func (e ErrorCode) String() string

type Failure

type Failure struct {
	Message    string       `json:"message"`
	Screen     string       `json:"screen"`     // base64-encoded screenshot of page
	Class      string       `json:"class"`      // class name for exception thrown
	StackTrace []StackFrame `json:"stackTrace"` // stack trace for exception
}

type Session

type Session struct {
	ID           string `json:"id"`
	Capabilities `json:"capabilities"`
	// contains filtered or unexported fields
}

func (*Session) ActiveElement

func (s *Session) ActiveElement() (*Element, error)

func (*Session) AlertCancel

func (s *Session) AlertCancel() error

func (*Session) AlertOK

func (s *Session) AlertOK() error

func (*Session) AlertText

func (s *Session) AlertText() (string, error)

func (*Session) Back

func (s *Session) Back() error

func (*Session) CloseWindow

func (s *Session) CloseWindow() error

func (*Session) Delete

func (s *Session) Delete() error

func (*Session) Element

func (s *Session) Element(by Strategy, desc string) (*Element, error)

func (*Session) Elements

func (s *Session) Elements(by Strategy, desc string) ([]*Element, error)

func (*Session) Forward

func (s *Session) Forward() error

func (*Session) Orientation

func (s *Session) Orientation() (string, error)

func (*Session) Refresh

func (s *Session) Refresh() error

func (*Session) SetOrientation

func (s *Session) SetOrientation(orientation string) error

func (*Session) SetTimeout

func (s *Session) SetTimeout(t Timeout, d time.Duration) error

func (*Session) SetURL

func (s *Session) SetURL(url string) error

func (*Session) SetWindow

func (s *Session) SetWindow(w *Window) error

func (*Session) Source

func (s *Session) Source() (string, error)

func (*Session) Title

func (s *Session) Title() (string, error)

func (*Session) URL

func (s *Session) URL() (string, error)

func (*Session) Window

func (s *Session) Window() (*Window, error)

func (*Session) Windows

func (s *Session) Windows() ([]*Window, error)

type StackFrame

type StackFrame struct {
	File   string `json:"fileName"`   // name of source file
	Line   int    `json:"lineNumber"` // line number in source file
	Class  string `json:"className"`  // class active in this frame
	Method string `json:"methodName"` // method active in this frame
}

type Status

type Status struct {
	Build struct {
		Version  string `json:"version"`  // release label
		Revision string `json:"revision"` // revision of local source control client
		Time     string `json:"time"`     // build timestamp (format unspecified)
	} `json:"build"`
	OS struct {
		Arch    string `json:"arch"`    // system architecture
		Name    string `json:"name"`    // name of operating system
		Version string `json:"version"` // version of operating system
	} `json:"os"`
}

type Strategy

type Strategy string
const (
	ByClassName       Strategy = "class name"
	ByCSSSelector     Strategy = "css selector"
	ByID              Strategy = "id"
	ByName            Strategy = "name"
	ByLinkText        Strategy = "link text"
	ByPartialLinkText Strategy = "partial link text"
	ByTagName         Strategy = "tag name"
	ByXPath           Strategy = "xpath"
)

type Timeout

type Timeout string
const (
	ScriptTimeout       Timeout = "script"
	ImplicitTimeout     Timeout = "implicit"
	PageLoadTimeout     Timeout = "page load"
	AsyncScriptTimeout          = "/async_script"
	ImplicitWaitTimeout Timeout = "/implicit_wait"
)

type Window

type Window struct {
	ID string
	// contains filtered or unexported fields
}

func (*Window) Maximize

func (w *Window) Maximize() error

func (*Window) Position

func (w *Window) Position() (x, y int, err error)

func (*Window) Resize

func (w *Window) Resize(dx, dy int) error

func (*Window) Size

func (w *Window) Size() (dx, dy int, err error)

Jump to

Keyboard shortcuts

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