webdriver

package module
v0.0.0-...-62ca8f6 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2019 License: Apache-2.0 Imports: 12 Imported by: 0

README

webdriver

Webdriver is a package enabling programmatic control of a WebDriver instance for Golang.

Features
Installation
go get github.com/abcum/webdriver

Documentation

Index

Constants

View Source
const (
	// FindByClass finds eelements whose class name contains the search value.
	FindByClass FindStrategy = "class name"
	// FindByCss finds elements matching a CSS selector.
	FindByCss = "css selector"
	// FindById finds elements whose ID attribute matches the search value.
	FindById = "id"
	// FindByName an element whose NAME attribute matches the search value.
	FindByName = "name"
	// FindByLinkText finds links whose visible text matches the search value.
	FindByLinkText = "link text"
	// FindByPartialLinkText finds links whose text partially matches the search value.
	FindByPartialLinkText = "partial link text"
	// FindByTagName finds elements whose tag name matches the search value.
	FindByTagName = "tag name"
	// XPath finds elements matching an XPath expression.
	XPath = "xpath"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cookie struct {
	Name   string `json:"name"`
	Value  string `json:"value"`
	Path   string `json:"path"`
	Domain string `json:"domain"`
	Secure bool   `json:"secure"`
	Expiry int    `json:"expiry"`
	// contains filtered or unexported fields
}

Cookie represents a web cookie.

func (*Cookie) Clear

func (c *Cookie) Clear() error

Clear removes the cookie from the current session.

func (*Cookie) Set

func (c *Cookie) Set() error

Set saves the cookie to the current session.

type Driver

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

Driver represents a WebDriver instance

func NewDriver

func NewDriver(url, exe string) *Driver

NewDriver creates a new driver instance.

func (*Driver) Session

func (w *Driver) Session(desired, required map[string]interface{}) (*Session, error)

Session creates a new WebDriver session, launching a new remote browser instance.

func (*Driver) Sessions

func (w *Driver) Sessions() ([]*Session, error)

Sessions returns all of the currently active browser sessions.

func (*Driver) Start

func (w *Driver) Start() error

func (*Driver) Stop

func (w *Driver) Stop() error

type Element

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

Element represents a web element within a page.

func (*Element) Attr

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

Attr returns the specified attribute value for the element.

func (*Element) Clear

func (e *Element) Clear() error

Clear clears the value of the current element (must be a text input box).

func (*Element) Click

func (e *Element) Click() error

Click clicks on the current element.

func (*Element) Css

func (e *Element) Css(name string) (string, error)

Css returns the specified computed css property for the element.

func (*Element) Displayed

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

Displayed returns whether the current element is displayed or not.

func (*Element) Element

func (e *Element) Element(using FindStrategy, value string) (*Element, error)

Element searches for a single element on the page, starting from this element.

func (*Element) Elements

func (e *Element) Elements(using FindStrategy, value string) ([]*Element, error)

Elements searches for multiple elements on the page, starting from this element.

func (*Element) Enabled

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

Enabled returns whether the current element is enabled or not.

func (*Element) Equals

func (e *Element) Equals(o *Element) (bool, error)

Equals returns true if this element is the same as another element.

func (*Element) Html

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

Html returns the outer html of the element.

func (*Element) Location

func (e *Element) Location() (*pos, error)

Location returns the current location coordinates of the element.

func (*Element) Name

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

Name returns the node name of the element.

func (*Element) Selected

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

Selected returns whether the current element is selected or not.

func (*Element) Size

func (e *Element) Size() (*size, error)

Size returns the size of the element.

func (*Element) Submit

func (e *Element) Submit() error

Submit submits the current element (must be a form).

func (*Element) Text

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

Text returns the visible text for the element.

func (*Element) Value

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

Value sends a sequence of key strokes to the element.

type FindStrategy

type FindStrategy string

FindStrategy specifies which strategy to use when searching for elements.

type Session

type Session struct {
	ID string                 `json:"id"`
	CB map[string]interface{} `json:"capabilities"`
	// contains filtered or unexported fields
}

Session represents a web page session.

func (*Session) AcceptAlert

func (s *Session) AcceptAlert() error

AcceptAlert accepts the currently displayed alert dialog window.

func (*Session) Active

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

Active returns the currently active element within the current page.

func (*Session) AlertText

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

AlertText returns the text of the currently displayed dialog window.

func (*Session) ApplicationCacheStatus

func (s *Session) ApplicationCacheStatus() (int, error)

ApplicationCacheStatus returns the current application cache status for the current page.

func (*Session) Back

func (s *Session) Back() error

Back causes the browser to traverse one step backwards in the session history.

func (*Session) ButtonDown

func (s *Session) ButtonDown(button int) error

ButtonDown clicks and holds the specified mouse button at the current coordinates.

func (*Session) ButtonUp

func (s *Session) ButtonUp(button int) error

ButtonUp releases the specified mouse button at the current coordinates.

func (*Session) Click

func (s *Session) Click(button int) error

Click clicks the specified mouse button at the current coordinates.

func (*Session) Cookie

func (s *Session) Cookie(name string) *Cookie

Cookie returns a new cookie which can be set within the page.

func (*Session) Cookies

func (s *Session) Cookies() ([]Cookie, error)

Cookies returns all of the cookies visible to the current page.

func (*Session) CookiesClear

func (s *Session) CookiesClear() error

CookiesClear removes all cookies visible to the current page.

func (*Session) Delete

func (s *Session) Delete() error

Delete deletes the current session, freeing resources.

func (*Session) DismissAlert

func (s *Session) DismissAlert() error

DismissAlert cancels the currently displayed alert dialog window.

func (*Session) DoubleClick

func (s *Session) DoubleClick() error

DoubleClick double clicks the left mouse button at the current coordinates.

func (*Session) Element

func (s *Session) Element(using FindStrategy, value string) (*Element, error)

Element searches for a single element from within the current page.

func (*Session) Elements

func (s *Session) Elements(using FindStrategy, value string) ([]*Element, error)

Elements searches for multiple elements from within the current page.

func (*Session) ExecuteAsync

func (s *Session) ExecuteAsync(script string, args []interface{}) ([]byte, error)

ExecuteAsync executes a JavaScript script asynchronously in the current page.

func (*Session) ExecuteSync

func (s *Session) ExecuteSync(script string, args []interface{}) ([]byte, error)

ExecuteSync executes a JavaScript script synchronously in the current page.

func (*Session) Forward

func (s *Session) Forward() error

Forward causes the browser to traverse one step forwards in the session history.

func (*Session) Load

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

Load loads a new url in the current page.

func (*Session) LocalStorageClear

func (s *Session) LocalStorageClear() error

LocalStorageClear clears the localStorage of the current page.

func (*Session) LocalStorageDelKey

func (s *Session) LocalStorageDelKey(key string) error

LocalStorageDelKey deletes the specified key from localStorage on the current page.

func (*Session) LocalStorageGetKey

func (s *Session) LocalStorageGetKey(key string) (string, error)

LocalStorageGetKey gets the specified localStorage key on the current page.

func (*Session) LocalStorageKeys

func (s *Session) LocalStorageKeys() ([]string, error)

LocalStorageKeys returns all of the localStorage keys for the current page.

func (*Session) LocalStorageSetKey

func (s *Session) LocalStorageSetKey(key, value string) error

LocalStorageSetKey sets the specified key in localStorage on the current page.

func (*Session) LocalStorageSize

func (s *Session) LocalStorageSize() (int, error)

LocalStorageSize returns the current localStorage content size.

func (*Session) Move

func (s *Session) Move(e *Element, x, y int) error

Move moves the mouse by an offset from the specified element.

func (*Session) Refresh

func (s *Session) Refresh() error

Refresh causes the browser to reload the curretn page.

func (*Session) RespondAlert

func (s *Session) RespondAlert(text string) error

RespondAlert sends keystrokes to the currently displayed dialog window.

func (*Session) Screenshot

func (s *Session) Screenshot() (io.Reader, error)

Screenshot takes a screenshot of the full browser viewport.

func (*Session) SessionStorageClear

func (s *Session) SessionStorageClear() error

SessionStorageClear clears the sessionStorage of the current page.

func (*Session) SessionStorageDelKey

func (s *Session) SessionStorageDelKey(key string) error

SessionStorageDelKey deletes the specified key from sessionStorage on the current page.

func (*Session) SessionStorageGetKey

func (s *Session) SessionStorageGetKey(key string) (string, error)

SessionStorageGetKey gets the specified sessionStorage key on the current page.

func (*Session) SessionStorageKeys

func (s *Session) SessionStorageKeys() ([]string, error)

SessionStorageKeys returns all of the sessionStorage keys for the current page.

func (*Session) SessionStorageSetKey

func (s *Session) SessionStorageSetKey(key, value string) error

SessionStorageSetKey sets the specified key in sessionStorage on the current page.

func (*Session) SessionStorageSize

func (s *Session) SessionStorageSize() (int, error)

SessionStorageSize returns the current sessionStorage content size.

func (*Session) Source

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

Source gets the source code of the current page.

func (*Session) Timeouts

func (s *Session) Timeouts(what string, ms int) error

Timeouts enables specifying custom timeouts for the current session.

func (*Session) TimeoutsAsyncScript

func (s *Session) TimeoutsAsyncScript(ms int) error

TimeoutsAsyncScript specifies a custom timeout when running asynchronous scripts.

func (*Session) TimeoutsImplicitWait

func (s *Session) TimeoutsImplicitWait(ms int) error

TimeoutsImplicitWait specifies a custom timeout when searching for elements on the page.

func (*Session) Title

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

Title gets the title of the current page.

func (*Session) TouchClick

func (s *Session) TouchClick(e *Element) error

TouchClick executes a single tap at the current coordinates.

func (*Session) TouchDoubleClick

func (s *Session) TouchDoubleClick(e *Element) error

TouchDoubleClick executes a double click on the specified element.

func (*Session) TouchDown

func (s *Session) TouchDown(x, y int) error

TouchDown presses a finger down on the page at the current coordinates.

func (*Session) TouchFlick

func (s *Session) TouchFlick(e *Element, x, y, speed int) error

TouchFlick flicks a finger on the screen starting at the specified element.

func (*Session) TouchFlickAnywhere

func (s *Session) TouchFlickAnywhere(xspeed, yspeed int) error

TouchFlickAnywhere flicks a finger on the screen starting anywhere.

func (*Session) TouchLongClick

func (s *Session) TouchLongClick(e *Element) error

TouchLongClick executes a long tap on the specified element.

func (*Session) TouchMove

func (s *Session) TouchMove(x, y int) error

TouchMove moves the currently pressed finsed on the page.

func (*Session) TouchScroll

func (s *Session) TouchScroll(e *Element, x, y int) error

TouchScroll scrolls on the page using finger based motion events.

func (*Session) TouchUp

func (s *Session) TouchUp(x, y int) error

TouchUp lifts a finger up from the page at the current coordinates.

func (*Session) Url

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

Url gets the url of the current page.

func (*Session) Window

func (s *Session) Window() *Window

Window gets the current active window.

type Window

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

Window represents a browser window.

func (*Window) Close

func (w *Window) Close() error

Close closes the window.

func (*Window) Maximize

func (w *Window) Maximize() error

Maximize maximizes the browser window.

func (*Window) Minimize

func (w *Window) Minimize() error

Minimize minimizes the browser window.

func (*Window) Resize

func (w *Window) Resize(width, height int) error

Resize resizes the window to the specified size.

Jump to

Keyboard shortcuts

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