agouti: github.com/sclevine/agouti Index | Files | Directories

package agouti

import "github.com/sclevine/agouti"

Package agouti is a universal WebDriver client for Go. It extends the agouti/api package to provide a feature-rich interface for controlling a web browser.

Index

Package Files

agouti.go capabilities.go multiselection.go options.go page.go selectable.go selection.go selection_actions.go selection_frames.go selection_properties.go types.go webdriver.go

type Button Uses

type Button int
const (
    LeftButton Button = iota
    MiddleButton
    RightButton
)

func (Button) String Uses

func (b Button) String() string

type Capabilities Uses

type Capabilities map[string]interface{}

A Capabilities instance defines the desired capabilities the WebDriver should use to configure a Page.

For example, to open Firefox with JavaScript disabled:

capabilities := agouti.NewCapabilities().Browser("firefox").Without("javascriptEnabled")
driver.NewPage(agouti.Desired(capabilities))

See: https://code.google.com/p/selenium/wiki/DesiredCapabilities

All methods called on this instance will modify the original instance.

func NewCapabilities Uses

func NewCapabilities(features ...string) Capabilities

NewCapabilities returns a Capabilities instance with any provided features enabled.

func (Capabilities) Browser Uses

func (c Capabilities) Browser(name string) Capabilities

Browser sets the desired browser name. Possible values:

{android|chrome|firefox|htmlunit|internet explorer|iPhone|iPad|opera|safari}

func (Capabilities) JSON Uses

func (c Capabilities) JSON() (string, error)

JSON returns a JSON string representing the desired capabilities.

func (Capabilities) Platform Uses

func (c Capabilities) Platform(platform string) Capabilities

Platform sets the desired browser platform. Possible values:

{WINDOWS|XP|VISTA|MAC|LINUX|UNIX|ANDROID|ANY}.

func (Capabilities) Proxy Uses

func (c Capabilities) Proxy(p ProxyConfig) Capabilities

Proxy sets the desired proxy configuration.

func (Capabilities) Version Uses

func (c Capabilities) Version(version string) Capabilities

Version sets the desired browser version (ex. "3.6").

func (Capabilities) With Uses

func (c Capabilities) With(feature string) Capabilities

With enables the provided feature (ex. "trustAllSSLCertificates").

func (Capabilities) Without Uses

func (c Capabilities) Without(feature string) Capabilities

Without disables the provided feature (ex. "javascriptEnabled").

type Click Uses

type Click int
const (
    SingleClick Click = iota
    HoldClick
    ReleaseClick
)

func (Click) String Uses

func (c Click) String() string

type Log Uses

type Log struct {
    // Message is the text of the log message.
    Message string

    // Location is the code location of the log message, if present
    Location string

    // Level is the log level ("DEBUG", "INFO", "WARNING", or "SEVERE").
    Level string

    // Time is the time the message was logged.
    Time time.Time
}

A Log represents a single log message

type MultiSelection Uses

type MultiSelection struct {
    Selection
}

A MultiSelection is a Selection that may be indexed using the At() method. All Selection methods are available on a MultiSelection.

A Selection returned by At() may still refer to multiple elements if any parent of the MultiSelection refers to multiple elements.

Examples:

selection.All("section").All("form").At(1).Submit()

Submits the second form in each section.

selection.All("div").Find("h1").Click()

Clicks one h1 in each div, failing if any div does not contain exactly one h1.

func (*MultiSelection) All Uses

func (s *MultiSelection) All(selector string) *MultiSelection

All finds zero or more elements by CSS selector.

func (*MultiSelection) AllByButton Uses

func (s *MultiSelection) AllByButton(text string) *MultiSelection

AllByButton finds zero or more button elements with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*MultiSelection) AllByClass Uses

func (s *MultiSelection) AllByClass(text string) *MultiSelection

AllByClass finds zero or more elements with a given CSS class.

func (*MultiSelection) AllByID Uses

func (s *MultiSelection) AllByID(text string) *MultiSelection

AllByID finds zero or more elements with a given ID.

func (*MultiSelection) AllByLabel Uses

func (s *MultiSelection) AllByLabel(text string) *MultiSelection

AllByLabel finds zero or more elements by associated label text.

func (s *MultiSelection) AllByLink(text string) *MultiSelection

AllByLink finds zero or more anchor elements by their text content.

func (*MultiSelection) AllByName Uses

func (s *MultiSelection) AllByName(name string) *MultiSelection

AllByName finds zero or more elements with the provided name attribute.

func (*MultiSelection) AllByXPath Uses

func (s *MultiSelection) AllByXPath(selector string) *MultiSelection

AllByXPath finds zero or more elements by XPath selector.

func (*MultiSelection) At Uses

func (s *MultiSelection) At(index int) *Selection

At finds an element at the provided index. It only applies to the immediate selection, meaning that the returned selection may still refer to multiple elements if any parent of the immediate selection is also a *MultiSelection.

func (*MultiSelection) Find Uses

func (s *MultiSelection) Find(selector string) *Selection

Find finds exactly one element by CSS selector.

func (*MultiSelection) FindByButton Uses

func (s *MultiSelection) FindByButton(text string) *Selection

FindByButton finds exactly one button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*MultiSelection) FindByClass Uses

func (s *MultiSelection) FindByClass(text string) *Selection

FindByClass finds exactly one element with a given CSS class.

func (*MultiSelection) FindByID Uses

func (s *MultiSelection) FindByID(id string) *Selection

FindByID finds exactly one element that has the given ID.

func (*MultiSelection) FindByLabel Uses

func (s *MultiSelection) FindByLabel(text string) *Selection

FindByLabel finds exactly one element by associated label text.

func (s *MultiSelection) FindByLink(text string) *Selection

FindByLink finds exactly one anchor element by its text content.

func (*MultiSelection) FindByName Uses

func (s *MultiSelection) FindByName(name string) *Selection

FindByName finds exactly element with the provided name attribute.

func (*MultiSelection) FindByXPath Uses

func (s *MultiSelection) FindByXPath(selector string) *Selection

FindByXPath finds exactly one element by XPath selector.

func (*MultiSelection) FindForAppium Uses

func (s *MultiSelection) FindForAppium(selectorType string, text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*MultiSelection) First Uses

func (s *MultiSelection) First(selector string) *Selection

First finds the first element by CSS selector.

func (*MultiSelection) FirstByButton Uses

func (s *MultiSelection) FirstByButton(text string) *Selection

FirstByButton finds the first button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*MultiSelection) FirstByClass Uses

func (s *MultiSelection) FirstByClass(text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*MultiSelection) FirstByLabel Uses

func (s *MultiSelection) FirstByLabel(text string) *Selection

FirstByLabel finds the first element by associated label text.

func (s *MultiSelection) FirstByLink(text string) *Selection

FirstByLink finds the first anchor element by its text content.

func (*MultiSelection) FirstByName Uses

func (s *MultiSelection) FirstByName(name string) *Selection

FirstByName finds the first element with the provided name attribute.

func (*MultiSelection) FirstByXPath Uses

func (s *MultiSelection) FirstByXPath(selector string) *Selection

FirstByXPath finds the first element by XPath selector.

func (*MultiSelection) Selectors Uses

func (s *MultiSelection) Selectors() Selectors

type Option Uses

type Option func(*config)

An Option specifies configuration for a new WebDriver or Page.

var Debug Option = func(c *config) {
    c.Debug = true
}

Debug is an Option that connects the running WebDriver to stdout and stdin.

var RejectInvalidSSL Option = func(c *config) {
    c.RejectInvalidSSL = true
}

RejectInvalidSSL is an Option specifying that the WebDriver should reject invalid SSL certificates. All WebDrivers should accept invalid SSL certificates by default. See: http://www.w3.org/TR/webdriver/#invalid-ssl-certificates

func Browser Uses

func Browser(name string) Option

Browser provides an Option for specifying a browser.

func Desired Uses

func Desired(capabilities Capabilities) Option

Desired provides an Option for specifying desired WebDriver Capabilities.

func HTTPClient Uses

func HTTPClient(client *http.Client) Option

HTTPClient provides an Option for specifying a *http.Client

func Timeout Uses

func Timeout(seconds int) Option

Timeout provides an Option for specifying a timeout in seconds.

type Page Uses

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

A Page represents an open browser session. Pages may be created using the *WebDriver.Page() method or by calling the NewPage or SauceLabs functions.

func JoinPage Uses

func JoinPage(url string) *Page

JoinPage creates a Page using existing session URL.

func NewPage Uses

func NewPage(url string, options ...Option) (*Page, error)

NewPage opens a Page using the provided WebDriver URL. This method takes the same Options as *WebDriver.NewPage. Unlike *WebDriver.NewPage, this method will respect the HTTPClient Option if provided.

func SauceLabs Uses

func SauceLabs(name, platform, browser, version, username, accessKey string, options ...Option) (*Page, error)

SauceLabs opens a Sauce Labs session and returns a *Page. Does not support Sauce Connect.

This method takes the same Options as NewPage. Passing the Desired Option will completely override the provided name, platform, browser, and version.

func (*Page) All Uses

func (s *Page) All(selector string) *MultiSelection

All finds zero or more elements by CSS selector.

func (*Page) AllByButton Uses

func (s *Page) AllByButton(text string) *MultiSelection

AllByButton finds zero or more button elements with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Page) AllByClass Uses

func (s *Page) AllByClass(text string) *MultiSelection

AllByClass finds zero or more elements with a given CSS class.

func (*Page) AllByID Uses

func (s *Page) AllByID(text string) *MultiSelection

AllByID finds zero or more elements with a given ID.

func (*Page) AllByLabel Uses

func (s *Page) AllByLabel(text string) *MultiSelection

AllByLabel finds zero or more elements by associated label text.

func (s *Page) AllByLink(text string) *MultiSelection

AllByLink finds zero or more anchor elements by their text content.

func (*Page) AllByName Uses

func (s *Page) AllByName(name string) *MultiSelection

AllByName finds zero or more elements with the provided name attribute.

func (*Page) AllByXPath Uses

func (s *Page) AllByXPath(selector string) *MultiSelection

AllByXPath finds zero or more elements by XPath selector.

func (*Page) Back Uses

func (p *Page) Back() error

Back navigates backwards in history.

func (*Page) CancelPopup Uses

func (p *Page) CancelPopup() error

CancelPopup cancels an alert, confirm, or prompt popup.

func (*Page) ClearCookies Uses

func (p *Page) ClearCookies() error

ClearCookies deletes all cookies on the page.

func (*Page) Click Uses

func (p *Page) Click(event Click, button Button) error

Click performs the provided Click event using the provided Button at the current mouse position.

func (*Page) CloseWindow Uses

func (p *Page) CloseWindow() error

CloseWindow closes the active window.

func (*Page) ConfirmPopup Uses

func (p *Page) ConfirmPopup() error

ConfirmPopup confirms an alert, confirm, or prompt popup.

func (*Page) DeleteCookie Uses

func (p *Page) DeleteCookie(name string) error

DeleteCookie deletes a cookie on the page by name.

func (*Page) Destroy Uses

func (p *Page) Destroy() error

Destroy closes any open browsers by ending the session.

func (*Page) DoubleClick Uses

func (p *Page) DoubleClick() error

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

func (*Page) EnterPopupText Uses

func (p *Page) EnterPopupText(text string) error

EnterPopupText enters text into an open prompt popup.

func (*Page) Find Uses

func (s *Page) Find(selector string) *Selection

Find finds exactly one element by CSS selector.

func (*Page) FindByButton Uses

func (s *Page) FindByButton(text string) *Selection

FindByButton finds exactly one button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Page) FindByClass Uses

func (s *Page) FindByClass(text string) *Selection

FindByClass finds exactly one element with a given CSS class.

func (*Page) FindByID Uses

func (s *Page) FindByID(id string) *Selection

FindByID finds exactly one element that has the given ID.

func (*Page) FindByLabel Uses

func (s *Page) FindByLabel(text string) *Selection

FindByLabel finds exactly one element by associated label text.

func (s *Page) FindByLink(text string) *Selection

FindByLink finds exactly one anchor element by its text content.

func (*Page) FindByName Uses

func (s *Page) FindByName(name string) *Selection

FindByName finds exactly element with the provided name attribute.

func (*Page) FindByXPath Uses

func (s *Page) FindByXPath(selector string) *Selection

FindByXPath finds exactly one element by XPath selector.

func (*Page) FindForAppium Uses

func (s *Page) FindForAppium(selectorType string, text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*Page) First Uses

func (s *Page) First(selector string) *Selection

First finds the first element by CSS selector.

func (*Page) FirstByButton Uses

func (s *Page) FirstByButton(text string) *Selection

FirstByButton finds the first button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Page) FirstByClass Uses

func (s *Page) FirstByClass(text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*Page) FirstByLabel Uses

func (s *Page) FirstByLabel(text string) *Selection

FirstByLabel finds the first element by associated label text.

func (s *Page) FirstByLink(text string) *Selection

FirstByLink finds the first anchor element by its text content.

func (*Page) FirstByName Uses

func (s *Page) FirstByName(name string) *Selection

FirstByName finds the first element with the provided name attribute.

func (*Page) FirstByXPath Uses

func (s *Page) FirstByXPath(selector string) *Selection

FirstByXPath finds the first element by XPath selector.

func (*Page) Forward Uses

func (p *Page) Forward() error

Forward navigates forward in history.

func (*Page) GetCookies Uses

func (p *Page) GetCookies() ([]*http.Cookie, error)

GetCookies returns all cookies on the page.

func (*Page) HTML Uses

func (p *Page) HTML() (string, error)

HTML returns the current contents of the DOM for the entire page.

func (*Page) LogTypes Uses

func (p *Page) LogTypes() ([]string, error)

LogTypes returns all of the valid log types that may be used with a LogReader.

func (*Page) MoveMouseBy Uses

func (p *Page) MoveMouseBy(xOffset, yOffset int) error

MoveMouseBy moves the mouse by the provided offset.

func (*Page) Navigate Uses

func (p *Page) Navigate(url string) error

Navigate navigates to the provided URL.

func (*Page) NextWindow Uses

func (p *Page) NextWindow() error

NextWindow switches to the next available window.

func (*Page) PopupText Uses

func (p *Page) PopupText() (string, error)

PopupText returns the current alert, confirm, or prompt popup text.

func (*Page) ReadAllLogs Uses

func (p *Page) ReadAllLogs(logType string) ([]Log, error)

ReadAllLogs returns all log messages of the provided log type. For example, page.ReadAllLogs("browser") returns browser console logs, such as JavaScript logs and errors. All logs since the session was created are returned. Valid log types may be obtained using the LogTypes method.

func (*Page) ReadNewLogs Uses

func (p *Page) ReadNewLogs(logType string) ([]Log, error)

ReadNewLogs returns new log messages of the provided log type. For example, page.ReadNewLogs("browser") returns browser console logs, such as JavaScript logs and errors. Only logs since the last call to ReadNewLogs are returned. Valid log types may be obtained using the LogTypes method.

func (*Page) Refresh Uses

func (p *Page) Refresh() error

Refresh refreshes the page.

func (*Page) Reset Uses

func (p *Page) Reset() error

Reset deletes all cookies set for the current domain and navigates to a blank page. Unlike Destroy, Reset will permit the page to be re-used after it is called. Reset is faster than Destroy, but any cookies from domains outside the current domain will remain after a page is reset.

func (*Page) RunScript Uses

func (p *Page) RunScript(body string, arguments map[string]interface{}, result interface{}) error

RunScript runs the JavaScript provided in the body. Any keys present in the arguments map will be available as variables in the body. Values provided in arguments are converted into javascript objects. If the body returns a value, it will be unmarshalled into the result argument. Simple example:

var number int
page.RunScript("return test;", map[string]interface{}{"test": 100}, &number)
fmt.Println(number)

-> 100

func (*Page) Screenshot Uses

func (p *Page) Screenshot(filename string) error

Screenshot takes a screenshot and saves it to the provided filename. The provided filename may be an absolute or relative path.

func (*Page) Selectors Uses

func (s *Page) Selectors() Selectors

func (*Page) Session Uses

func (p *Page) Session() *api.Session

Session returns a *api.Session that can be used to send direct commands to the WebDriver. See: https://code.google.com/p/selenium/wiki/JsonWireProtocol

func (*Page) SetCookie Uses

func (p *Page) SetCookie(cookie *http.Cookie) error

SetCookie sets a cookie on the page.

func (*Page) SetImplicitWait Uses

func (p *Page) SetImplicitWait(timeout int) error

SetImplicitWait sets the implicit wait timeout (in ms)

func (*Page) SetPageLoad Uses

func (p *Page) SetPageLoad(timeout int) error

SetPageLoad sets the page load timeout (in ms)

func (*Page) SetScriptTimeout Uses

func (p *Page) SetScriptTimeout(timeout int) error

SetScriptTimeout sets the script timeout (in ms)

func (*Page) Size Uses

func (p *Page) Size(width, height int) error

Size sets the current page size in pixels.

func (*Page) String Uses

func (p *Page) String() string

String returns a string representation of the Page. Currently: "page"

func (*Page) SwitchToParentFrame Uses

func (p *Page) SwitchToParentFrame() error

SwitchToParentFrame focuses on the immediate parent frame of a frame selected by Selection.Frame. After switching, all new and existing selections will refer to the parent frame. All further Page methods will apply to this frame as well.

This method is not supported by PhantomJS. Please use SwitchToRootFrame instead.

func (*Page) SwitchToRootFrame Uses

func (p *Page) SwitchToRootFrame() error

SwitchToRootFrame focuses on the original, default page frame before any calls to Selection.Frame were made. After switching, all new and existing selections will refer to the root frame. All further Page methods will apply to this frame as well.

func (*Page) SwitchToWindow Uses

func (p *Page) SwitchToWindow(name string) error

SwitchToWindow switches to the first available window with the provided name (JavaScript `window.name` attribute).

func (*Page) Title Uses

func (p *Page) Title() (string, error)

Title returns the page title.

func (*Page) URL Uses

func (p *Page) URL() (string, error)

URL returns the current page URL.

func (*Page) WindowCount Uses

func (p *Page) WindowCount() (int, error)

WindowCount returns the number of available windows.

type ProxyConfig Uses

type ProxyConfig struct {
    ProxyType          string `json:"proxyType"`
    ProxyAutoconfigURL string `json:"proxyAutoconfigUrl,omitempty"`
    FTPProxy           string `json:"ftpProxy,omitempty"`
    HTTPProxy          string `json:"httpProxy,omitempty"`
    SSLProxy           string `json:"sslProxy,omitempty"`
    SOCKSProxy         string `json:"socksProxy,omitempty"`
    SOCKSUsername      string `json:"socksUsername,omitempty"`
    SOCKSPassword      string `json:"socksPassword,omitempty"`
    NoProxy            string `json:"noProxy,omitempty"`
}

A ProxyConfig instance defines the desired proxy configuration the WebDriver should use to proxy a Page.

ProxyType is required and defines the type of proxy being used
Possible Values:
    {direct|manual|pac|autodetect|system}

See: https://github.com/SeleniumHQ/selenium/wiki/DesiredCapabilities#proxy-json-object

type Selection Uses

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

Selection instances refer to a selection of elements. All Selection methods are also MultiSelection methods.

Methods that take selectors apply their selectors to each element in the selection they are called on. If the selection they are called on refers to multiple elements, the resulting selection will refer to at least that many elements.

Examples:

selection.Find("table").All("tr").At(2).First("td input[type=checkbox]").Check()

Checks the first checkbox in the third row of the only table.

selection.Find("table").All("tr").Find("td").All("input[type=checkbox]").Check()

Checks all checkboxes in the first-and-only cell of each row in the only table.

func (*Selection) Active Uses

func (s *Selection) Active() (bool, error)

Active returns true if the single element that the selection refers to is active.

func (*Selection) All Uses

func (s *Selection) All(selector string) *MultiSelection

All finds zero or more elements by CSS selector.

func (*Selection) AllByButton Uses

func (s *Selection) AllByButton(text string) *MultiSelection

AllByButton finds zero or more button elements with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Selection) AllByClass Uses

func (s *Selection) AllByClass(text string) *MultiSelection

AllByClass finds zero or more elements with a given CSS class.

func (*Selection) AllByID Uses

func (s *Selection) AllByID(text string) *MultiSelection

AllByID finds zero or more elements with a given ID.

func (*Selection) AllByLabel Uses

func (s *Selection) AllByLabel(text string) *MultiSelection

AllByLabel finds zero or more elements by associated label text.

func (s *Selection) AllByLink(text string) *MultiSelection

AllByLink finds zero or more anchor elements by their text content.

func (*Selection) AllByName Uses

func (s *Selection) AllByName(name string) *MultiSelection

AllByName finds zero or more elements with the provided name attribute.

func (*Selection) AllByXPath Uses

func (s *Selection) AllByXPath(selector string) *MultiSelection

AllByXPath finds zero or more elements by XPath selector.

func (*Selection) Attribute Uses

func (s *Selection) Attribute(attribute string) (string, error)

Attribute returns an attribute value for exactly one element.

func (*Selection) CSS Uses

func (s *Selection) CSS(property string) (string, error)

CSS returns a CSS style property value for exactly one element.

func (*Selection) Check Uses

func (s *Selection) Check() error

Check checks all of the unchecked checkboxes that the selection refers to.

func (*Selection) Clear Uses

func (s *Selection) Clear() error

Clear clears all fields the selection refers to.

func (*Selection) Click Uses

func (s *Selection) Click() error

Click clicks on all of the elements that the selection refers to.

func (*Selection) Count Uses

func (s *Selection) Count() (int, error)

Count returns the number of elements that the selection refers to.

func (*Selection) DoubleClick Uses

func (s *Selection) DoubleClick() error

DoubleClick double-clicks on all of the elements that the selection refers to.

func (*Selection) Elements Uses

func (s *Selection) Elements() ([]*api.Element, error)

Elements returns a []*api.Element that can be used to send direct commands to WebDriver elements. See: https://code.google.com/p/selenium/wiki/JsonWireProtocol

func (*Selection) Enabled Uses

func (s *Selection) Enabled() (bool, error)

Enabled returns true if all of the elements that the selection refers to are enabled.

func (*Selection) EqualsElement Uses

func (s *Selection) EqualsElement(other interface{}) (bool, error)

EqualsElement returns whether or not two selections of exactly one element refer to the same element.

func (*Selection) Fill Uses

func (s *Selection) Fill(text string) error

Fill fills all of the fields the selection refers to with the provided text.

func (*Selection) Find Uses

func (s *Selection) Find(selector string) *Selection

Find finds exactly one element by CSS selector.

func (*Selection) FindByButton Uses

func (s *Selection) FindByButton(text string) *Selection

FindByButton finds exactly one button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Selection) FindByClass Uses

func (s *Selection) FindByClass(text string) *Selection

FindByClass finds exactly one element with a given CSS class.

func (*Selection) FindByID Uses

func (s *Selection) FindByID(id string) *Selection

FindByID finds exactly one element that has the given ID.

func (*Selection) FindByLabel Uses

func (s *Selection) FindByLabel(text string) *Selection

FindByLabel finds exactly one element by associated label text.

func (s *Selection) FindByLink(text string) *Selection

FindByLink finds exactly one anchor element by its text content.

func (*Selection) FindByName Uses

func (s *Selection) FindByName(name string) *Selection

FindByName finds exactly element with the provided name attribute.

func (*Selection) FindByXPath Uses

func (s *Selection) FindByXPath(selector string) *Selection

FindByXPath finds exactly one element by XPath selector.

func (*Selection) FindForAppium Uses

func (s *Selection) FindForAppium(selectorType string, text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*Selection) First Uses

func (s *Selection) First(selector string) *Selection

First finds the first element by CSS selector.

func (*Selection) FirstByButton Uses

func (s *Selection) FirstByButton(text string) *Selection

FirstByButton finds the first button element with the provided text. Supports <button>, <input type="button">, and <input type="submit">.

func (*Selection) FirstByClass Uses

func (s *Selection) FirstByClass(text string) *Selection

FirstByClass finds the first element with a given CSS class.

func (*Selection) FirstByLabel Uses

func (s *Selection) FirstByLabel(text string) *Selection

FirstByLabel finds the first element by associated label text.

func (s *Selection) FirstByLink(text string) *Selection

FirstByLink finds the first anchor element by its text content.

func (*Selection) FirstByName Uses

func (s *Selection) FirstByName(name string) *Selection

FirstByName finds the first element with the provided name attribute.

func (*Selection) FirstByXPath Uses

func (s *Selection) FirstByXPath(selector string) *Selection

FirstByXPath finds the first element by XPath selector.

func (*Selection) FlickFinger Uses

func (s *Selection) FlickFinger(xOffset, yOffset int, speed uint) error

FlickFinger performs a flick touch action by the provided offset and at the provided speed on exactly one element.

func (*Selection) MouseToElement Uses

func (s *Selection) MouseToElement() error

MouseToElement moves the mouse over exactly one element in the selection.

func (*Selection) ScrollFinger Uses

func (s *Selection) ScrollFinger(xOffset, yOffset int) error

ScrollFinger performs a scroll touch action by the provided offset on exactly one element.

func (*Selection) Select Uses

func (s *Selection) Select(text string) error

Select may be called on a selection of any number of <select> elements to select any <option> elements under those <select> elements that match the provided text.

func (*Selection) Selected Uses

func (s *Selection) Selected() (bool, error)

Selected returns true if all of the elements that the selection refers to are selected.

func (*Selection) Selectors Uses

func (s *Selection) Selectors() Selectors

func (*Selection) SendKeys Uses

func (s *Selection) SendKeys(key string) error

func (*Selection) String Uses

func (s *Selection) String() string

String returns a string representation of the selection, ex.

selection 'CSS: .some-class | XPath: //table [3] | Link "click me" [single]'

func (*Selection) Submit Uses

func (s *Selection) Submit() error

Submit submits all selected forms. The selection may refer to a form itself or any input element contained within a form.

func (*Selection) SwitchToFrame Uses

func (s *Selection) SwitchToFrame() error

SwitchToFrame focuses on the frame specified by the selection. All new and existing selections will refer to the new frame. All further Page methods will apply to this frame as well.

func (*Selection) Tap Uses

func (s *Selection) Tap(event Tap) error

Tap performs the provided Tap event on each element in the selection.

func (*Selection) Text Uses

func (s *Selection) Text() (string, error)

Text returns the entirety of the text content for exactly one element.

func (*Selection) Touch Uses

func (s *Selection) Touch(event Touch) error

Touch performs the provided Touch event at the location of each element in the selection.

func (*Selection) Uncheck Uses

func (s *Selection) Uncheck() error

Uncheck unchecks all of the checked checkboxes that the selection refers to.

func (*Selection) UploadFile Uses

func (s *Selection) UploadFile(filename string) error

UploadFile uploads the provided file to all selected <input type="file" />. The provided filename may be a relative or absolute path. Returns an error if elements of any other type are in the selection.

func (*Selection) Visible Uses

func (s *Selection) Visible() (bool, error)

Visible returns true if all of the elements that the selection refers to are visible.

type Selectors Uses

type Selectors interface {
    String() string
}

type Tap Uses

type Tap int
const (
    SingleTap Tap = iota
    DoubleTap
    LongTap
)

func (Tap) String Uses

func (t Tap) String() string

type Touch Uses

type Touch int
const (
    HoldFinger Touch = iota
    ReleaseFinger
    MoveFinger
)

func (Touch) String Uses

func (t Touch) String() string

type WebDriver Uses

type WebDriver struct {
    *api.WebDriver
    // contains filtered or unexported fields
}

A WebDriver controls a WebDriver process. This struct embeds api.WebDriver, which provides Start and Stop methods for starting and stopping the process.

func ChromeDriver Uses

func ChromeDriver(options ...Option) *WebDriver

ChromeDriver returns an instance of a ChromeDriver WebDriver.

Provided Options will apply as default arguments for new pages. New pages will accept invalid SSL certificates by default. This may be disabled using the RejectInvalidSSL Option.

func EdgeDriver Uses

func EdgeDriver(options ...Option) *WebDriver

EdgeDriver returns an instance of a EdgeDriver WebDriver.

Provided Options will apply as default arguments for new pages. New pages will accept invalid SSL certificates by default. This may be disabled using the RejectInvalidSSL Option.

func NewWebDriver Uses

func NewWebDriver(url string, command []string, options ...Option) *WebDriver

NewWebDriver returns an instance of a WebDriver specified by a templated URL and command. The URL should be the location of the WebDriver Wire Protocol web service brought up by the command. The command should be provided as a list of arguments (each of which are templated).

The Timeout Option specifies how many seconds to wait for the web service to become available. The default timeout is 5 seconds.

The HTTPClient Option specifies a *http.Client to use for all WebDriver communications. The default client is http.DefaultClient.

Any other provided Options are treated as default Options for new pages.

Valid template parameters are:

{{.Host}} - local address to bind to (usually 127.0.0.1)
{{.Port}} - arbitrary free port on the local address
{{.Address}} - {{.Host}}:{{.Port}}

Selenium JAR example:

command := []string{"java", "-jar", "selenium-server.jar", "-port", "{{.Port}}"}
agouti.NewWebDriver("http://{{.Address}}/wd/hub", command)

func PhantomJS Uses

func PhantomJS(options ...Option) *WebDriver

PhantomJS returns an instance of a PhantomJS WebDriver.

Provided Options will apply as default arguments for new pages. New pages will accept invalid SSL certificates by default. This may be disabled using the RejectInvalidSSL Option.

The RejectInvalidSSL Option must be provided to the PhantomJS function (and not the NewPage method) for this Option to take effect on any PhantomJS page.

func Selendroid Uses

func Selendroid(jarFile string, options ...Option) *WebDriver

Selendroid returns an instance of a Selendroid WebDriver.

Provided Options will apply as default arguments for new pages. New pages will accept invalid SSL certificates by default. This may be disabled using the RejectInvalidSSL Option.

The jarFile is a relative or absolute path to Selendroid JAR file. Selendroid will return nil if an invalid path is provided.

func Selenium Uses

func Selenium(options ...Option) *WebDriver

Selenium returns an instance of a Selenium WebDriver.

Provided Options will apply as default arguments for new pages. New pages will accept invalid SSL certificates by default. This may be disabled using the RejectInvalidSSL Option.

func (*WebDriver) NewPage Uses

func (w *WebDriver) NewPage(options ...Option) (*Page, error)

NewPage returns a *Page that corresponds to a new WebDriver session. Provided Options configure the page. For instance, to disable JavaScript:

capabilities := agouti.NewCapabilities().Without("javascriptEnabled")
driver.NewPage(agouti.Desired(capabilities))

For Selenium, a Browser Option (or a Desired Option with Capabilities that specify a Browser) must be provided. For instance:

seleniumDriver.NewPage(agouti.Browser("safari"))

Specific Options (such as Browser) have precedence over Capabilities specified by the Desired Option.

The HTTPClient Option will be ignored if passed to this function. New pages will always use the *http.Client provided to their WebDriver, or http.DefaultClient if none was provided.

Directories

PathSynopsis
apiPackage api provides a generic, low-level WebDriver API client for Go.
api/internal/bus
api/internal/mocks
api/internal/service
api/mobile
appium
internal/element
internal/integration
internal/matchers
internal/mocks
internal/target
matchersPackage matchers provides a set of Gomega-compatible matchers for use with the agouti package.
matchers/internal
matchers/internal/colorparser
matchers/internal/mocks

Package agouti imports 14 packages (graph) and is imported by 19 packages. Updated 2017-04-09. Refresh now. Tools for package owners.