Categorygithub.com/fasterthanlime/go-selenium
modulepackage
0.2.0
Repository: https://github.com/fasterthanlime/go-selenium.git
Documentation: pkg.go.dev

# README

go-selenium

Build Status GoDoc Go Report Card

Introduction

Yes, yet another Selenium Web Driver library has been brought to the table. This one, however, is slightly different.

  • Easy to understand.
  • Full test coverage by unit tests and integration tests.
  • Excellent support; we use this in our main project so if you find an issue - it'll likely impact us!
  • Idiomatic, structured code with no gimmicks.
  • Simple errors that describe what has happened and why.

Installation

As with all Go libraries, go-selenium is easy to install. Simply run the below command:

go get github.com/fasterthanlime/go-selenium

and then import the library in your project:

import "github.com/fasterthanlime/go-selenium"

Getting started

Prior to using this library you need to ensure that you have a Selenium instance running (standalone or grid is fine). If you don't know how to do this, there is a small section called 'Getting Selenium running' below.

Please see the examples/getting-started/main.go file.

Examples

Further examples, including tests of HackerNews (c), are available within the examples directory.

Documentation

All documentation is available on the godoc.org website: https://godoc.org/github.com/fasterthanlime/go-selenium.

Getting Selenium running

With Docker

  1. Choose an image from the following URL: https://github.com/SeleniumHQ/docker-selenium
  2. Execute the following Docker command replacing the image with your chosen one: docker run -d -p 4444:4444 --name selenium selenium/standalone-firefox.

Without Docker

  1. Download the Selenium standalone server from the following URL: http://www.seleniumhq.org/download/
  2. Download the appropriate web driver executable and include it in your path. For Firefox, that will be the Gecko driver.
  3. Run the Selenium server with the following command: java -jar selenium-server-standalone-3.0.1.jar.

# Packages

No description provided by the author
No description provided by the author

# Functions

AndroidBrowser returns an Android browser object.
ByCSSSelector accepts a CSS selector (i.e.
ByIndex accepts an integer that represents what the index of an element is and returns the appropriate By implementation.
ByLinkText is used to find an anchor element by its innerText.
ByPartialLinkText works the same way as ByLinkText but performs a search where the link text contains the string passed in instead of a full match.
ByXPath utilises the xpath to find elements (see http://www.guru99.com/xpath-selenium.html).
ChromeBrowser returns a Chrome browser object.
FirefoxBrowser returns a Firefox browser object.
HTMLUnitBrowser returns a HTMLUnit browser object.
InternetExplorerBrowser returns an IE browser object.
IPadBrowser returns an IPad browser object.
IPhoneBrowser returns an IPhone browser object.
IsCommunicationError checks whether an error is a selenium communication error.
IsInvalidURLError checks whether an error is due to the URL being incorrectly formatted.
IsMarshallingError checks whether an error is a marshalling error.
IsSessionIDError checks whether an error is due to a session ID not being set.
IsUnmarshallingError checks whether an error is a selenium unmarshalling error.
NewChromeOptions returns an empty set of ChromeOptions.
NewSeleniumWebDriver creates a new instance of a Selenium web driver with a service URL (usually http://domain:port/wd/hub) and a Capabilities object.
OperaBrowser returns an Opera browser object.
SafariBrowser returns a Safari browser object.
SessionImplicitWaitTimeout creates an appropriate timeout implementation for the session implicit wait timeout.
SessionPageLoadTimeout creates an appropriate Timeout implementation for the page load timeout.
SessionScriptTimeout creates an appropriate Timeout implementation for the script timeout.
UntilElementPresent attempts to locate an element on the page.
UntilURLIs checks whether or not the page's URL has changed.

# Constants

Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Error codes that are returned from Selenium.
Keyboard keys converted from the ASCII code.

# Structs

AcceptAlertResponse is the response returned from calling the AcceptAlert method.
AddCookieResponse is the result returned from calling the AddCookie method.
AlertTextResponse is the response returned from calling the AlertText method.
AllCookiesResponse is the response returned from the AllCookies method.
BackResponse is the response returned from the Back call.
Capabilities represents the capabilities defined in the W3C specification.
CloseWindowResponse is the response returned from the CloseWindow() method.
CommunicationError is the result of a communication failure between this library and the WebDriver API.
Cookie represents a browser cookie.
CookieResponse is the response returned from the Cookie method.
CreateSessionCapabilities is a summarisation of the capabilities returned from the CreateSession method.
CreateSessionResponse is the response returned from the API when the CreateSession() method does not throw an error.
CurrentURLResponse is the response returned from the GET Url call.
DeleteCookieResponse is the result returned from calling the DeleteCookie method.
DeleteSessionResponse is the response returned from the API when the DeleteSession() method does not thrown an error.
Dimensions is a type that is both returned and accept by functions.
DismissAlertResponse is the response returned from calling the DismissAlert method.
ElementAttributeResponse is the response returned from the Attribute call.
ElementClearResponse is the response returned from calling the Clear method.
ElementClickResponse is the response returned from calling the Click method.
ElementCSSValueResponse is the response returned when the CSSValue method is called on an Element implementation.
ElementDisplayedResponse is the response returned from the Displayed() call.
ElementEnabledResponse is the response returned from calling the Enabled method.
ElementMoveToResponse is the response returned from calling the MoveTo method.
ElementRectangleResponse is the response returned from calling the Rectangle method.
ElementSelectedResponse is the response returned from the Selected() call.
ElementSendKeysResponse is the response returned from calling the SendKeys method.
ElementTagNameResponse is the response returned from calling the TagName method.
ElementTextResponse is the response returned from calling the Text method.
ErrorResponse is what is returned from the Selenium API when an error occurs.
ExecuteScriptResponse is the response returned from calling the ExecuteScript method.
ForwardResponse is the response returned from the Forward call.
GoResponse is the response returned from the selenium web driver when calling the Go() call.
No description provided by the author
No description provided by the author
MarshallingError is an error that is returned when a json.Marshal error occurs.
MaximizeWindowResponse is the response that is returned from increasing the browser to match the viewport.
PageSourceResponse is the response returned from calling the PageSource method.
Rectangle repsents an elements size and position on the page.
RefreshResponse is the response returned from the Refresh call.
ScreenshotResponse is the response returned from the Screenshot and ScreenshotElement methods.
SendAlertTextResponse is the response returned from calling the SendAlertText method.
SessionStatusResponse is the response returned from the API when the SessionStatus() method is called.
SetSessionTimeoutResponse is the response returned from the API when the SetSessionTimeoutResponse() method is called.
SetWindowSizeResponse is the response that is returned from setting the window size of the current top level browsing context.
SwitchToFrameResponse is the response returned from the SwitchToFrame() method.
SwitchToParentFrameResponse represents the response from attempting to switch the top level browsing context to the parent of the current top level browsing context.
SwitchToWindowResponse is the response returned from the SwitchToWindow() method.
TitleResponse is the response returned from the Title call.
UnmarshallingError is the result of an unmarshalling failure of a JSON string.
WindowHandleResponse is the response returned from the WindowHandle() method.
WindowHandlesResponse is the response returned from the WindowHandles() method.
WindowSizeResponse is the response returned from calling the WindowSize method.

# Interfaces

Browser defines a supported selenium enabled browser.
By is an interface that defines what all 'ByX' methods must return.
ChromeOptions defines chromedriver-specific options.
Element is an interface which specifies what all WebDriver elements must do.
Timeout is an interface which specifies what all timeout requests must follow.
WebDriver is an interface which adheres to the W3C specification for WebDrivers (https://w3c.github.io/webdriver/webdriver-spec.html).

# Type aliases

InvalidURLError is an error that is returned whenever a URL is not correctly formatted.
SessionIDError is an error that is returned when the session id is invalid.
Until represents a function that will be continuously repeated until it succeeds or a timeout is reached.