# README
Go API client for api
Selenium WebDriver API specification
Overview
This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version: 1.0.0
- Build package: com.github.dsmontoya.webdriver.GoCustomGenerator
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/oauth2
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import api "github.com/dsmontoya/webdriver"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value sw.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), api.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value sw.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), api.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers
map in the Configuration
.
An operation is uniquely identified by "{classname}Service.{nickname}"
string.
Similar rules for overriding default operation server index and variables applies by using sw.ContextOperationServerIndices
and sw.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), api.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), api.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to http://localhost:4444/wd/hub
Class | Method | HTTP request | Description |
---|---|---|---|
ActionsApi | PerformActions | Post /session/{sessionId}/actions | Perform actions |
ActionsApi | ReleaseActions | Delete /session/{sessionId}/actions | Release actions |
AerokubeApi | DeleteRemoteFile | Delete /session/{sessionId}/aerokube/download/{fileName} | Deletes file in remote container with browser |
AerokubeApi | DownloadRemoteFile | Get /session/{sessionId}/aerokube/download/{fileName} | Downloads file from remote container with browser |
AerokubeApi | GetClipboard | Get /session/{sessionId}/aerokube/clipboard | Returns clipboard contents |
AerokubeApi | ListRemoteFiles | Get /session/{sessionId}/aerokube/download | Lists files in remote container with browser |
AerokubeApi | UpdateClipboard | Post /session/{sessionId}/aerokube/clipboard | Updates clipboard contents |
ContextsApi | CloseWindow | Delete /session/{sessionId}/window | Closes current window |
ContextsApi | CreateNewWindow | Post /session/{sessionId}/window/new | Creates a new window or tab |
ContextsApi | FullscreenWindow | Post /session/{sessionId}/window/fullscreen | Fullscreen window |
ContextsApi | GetWindowHandle | Get /session/{sessionId}/window | Returns current window handle |
ContextsApi | GetWindowHandles | Get /session/{sessionId}/window/handles | Returns all window handles |
ContextsApi | GetWindowRect | Get /session/{sessionId}/window/rect | Get window size |
ContextsApi | MaximizeWindow | Post /session/{sessionId}/window/maximize | Maximize window |
ContextsApi | MinimizeWindow | Post /session/{sessionId}/window/minimize | Minimize window |
ContextsApi | SetWindowRect | Post /session/{sessionId}/window/rect | Set window rect |
ContextsApi | SwitchToFrame | Post /session/{sessionId}/frame | Switch to frame |
ContextsApi | SwitchToParentFrame | Post /session/{sessionId}/frame/parent | Switch to parent frame |
ContextsApi | SwitchToWindow | Post /session/{sessionId}/window | Switches to window |
CookiesApi | AddCookie | Post /session/{sessionId}/cookie | Add cookie |
CookiesApi | DeleteAllCookies | Delete /session/{sessionId}/cookie | Delete all cookies |
CookiesApi | DeleteCookie | Delete /session/{sessionId}/cookie/{name} | Delete cookie |
CookiesApi | GetAllCookies | Get /session/{sessionId}/cookie | Get all cookies |
CookiesApi | GetNamedCookie | Get /session/{sessionId}/cookie/{name} | Get named cookie |
DocumentApi | ExecuteScript | Post /session/{sessionId}/execute/sync | Execute script |
DocumentApi | ExecuteScriptAsync | Post /session/{sessionId}/execute/async | Execute script asynchronously |
DocumentApi | GetPageSource | Get /session/{sessionId}/source | Get page source |
DocumentApi | UploadFile | Post /session/{sessionId}/file | Upload file |
ElementsApi | ElementClear | Post /session/{sessionId}/element/{elementId}/clear | Clear element |
ElementsApi | ElementClick | Post /session/{sessionId}/element/{elementId}/click | Click on element |
ElementsApi | ElementSendKeys | Post /session/{sessionId}/element/{elementId}/value | Send keys to element |
ElementsApi | FindElement | Post /session/{sessionId}/element | Find element |
ElementsApi | FindElementFromElement | Post /session/{sessionId}/element/{elementId}/element | Find element from element |
ElementsApi | FindElements | Post /session/{sessionId}/elements | Find elements |
ElementsApi | FindElementsFromElement | Post /session/{sessionId}/element/{elementId}/elements | Find elements from element |
ElementsApi | GetActiveElement | Get /session/{sessionId}/element/active | Get active element |
ElementsApi | GetElementAttribute | Get /session/{sessionId}/element/{elementId}/attribute/{name} | Get element attribute |
ElementsApi | GetElementCSSProperty | Get /session/{sessionId}/element/{elementId}/css/{propertyName} | Get element CSS property |
ElementsApi | GetElementComputedLabel | Get /session/{sessionId}/element/{elementId}/computedlabel | Get element computed accessibility label |
ElementsApi | GetElementComputedRole | Get /session/{sessionId}/element/{elementId}/computedrole | Get element computed accessibility role |
ElementsApi | GetElementProperty | Get /session/{sessionId}/element/{elementId}/property/{name} | Get element property |
ElementsApi | GetElementRect | Get /session/{sessionId}/element/{elementId}/rect | Get element rect |
ElementsApi | GetElementTagName | Get /session/{sessionId}/element/{elementId}/name | Get element tag name |
ElementsApi | GetElementText | Get /session/{sessionId}/element/{elementId}/text | Get element text |
ElementsApi | IsElementDisplayed | Get /session/{sessionId}/element/{elementId}/displayed | Is element displayed |
ElementsApi | IsElementEnabled | Get /session/{sessionId}/element/{elementId}/enabled | Is element enabled |
ElementsApi | IsElementSelected | Get /session/{sessionId}/element/{elementId}/selected | Is element selected |
MozillaApi | GetContext | Get /session/{sessionId}/moz/context | Get current context |
MozillaApi | InstallAddon | Post /session/{sessionId}/moz/addon/install | Install addon |
MozillaApi | SetContext | Post /session/{sessionId}/moz/context | Set current context |
MozillaApi | TakeFullScreenshot | Get /session/{sessionId}/moz/screenshot/full | Takes full page screenshot |
MozillaApi | UninstallAddon | Post /session/{sessionId}/moz/addon/uninstall | Uninstall addon |
NavigationApi | GetCurrentUrl | Get /session/{sessionId}/url | Returns current URL |
NavigationApi | GetPageTitle | Get /session/{sessionId}/title | Returns current page title |
NavigationApi | NavigateBack | Post /session/{sessionId}/back | Navigates to the previous page |
NavigationApi | NavigateForward | Post /session/{sessionId}/forward | Navigates to the next page |
NavigationApi | NavigateTo | Post /session/{sessionId}/url | Navigates to URL |
NavigationApi | RefreshPage | Post /session/{sessionId}/refresh | Reloads current page |
PrintApi | PrintPage | Post /session/{sessionId}/print | Print page to PDF |
PromptsApi | AcceptAlert | Post /session/{sessionId}/alert/accept | Accept alert |
PromptsApi | DismissAlert | Post /session/{sessionId}/alert/dismiss | Dismiss alert |
PromptsApi | GetAlertText | Get /session/{sessionId}/alert/text | Get alert text |
PromptsApi | SendAlertText | Post /session/{sessionId}/alert/text | Send alert text |
ScreenshotsApi | TakeElementScreenshot | Get /session/{sessionId}/element/{elementId}/screenshot | Takes element screenshot |
ScreenshotsApi | TakeScreenshot | Get /session/{sessionId}/screenshot | Takes page screenshot |
SessionsApi | CreateSession | Post /session | Creates new Selenium session |
SessionsApi | DeleteSession | Delete /session/{sessionId} | Deletes existing Selenium session |
SessionsApi | GetStatus | Get /status | Gets Selenium API status information |
TimeoutsApi | GetTimeouts | Get /session/{sessionId}/timeouts | Get session timeouts |
TimeoutsApi | SetTimeouts | Post /session/{sessionId}/timeouts | Adjusts session timeouts |
Documentation For Models
- Action
- ActionOrigin
- ActionSequence
- ActionSequenceParameters
- ActionsRequest
- AddonInstallRequest
- AddonUninstallRequest
- AnyResponse
- ArrayResponse
- BooleanResponse
- Capabilities
- ChromeOptions
- ChromiumLogLevel
- ClipboardData
- ContextRequest
- Cookie
- CookieRequest
- CookieResponse
- CookiesResponse
- EdgeOptions
- ElementSendKeysRequest
- EmptyResponse
- ErrorCode
- ErrorResponse
- ErrorResponseValue
- FileUploadRequest
- FileUploadResponse
- FindElementRequest
- FindElementResponse
- FindElementResponseValue
- FindElementsResponse
- FirefoxContext
- FirefoxLogLevel
- FirefoxOptions
- FirefoxOptionsLog
- FrameId
- GetWindowHandlesResponse
- KeyAction
- LocatorStrategy
- LogLevel
- LogType
- LoggingPrefs
- MobileEmulation
- MobileEmulationDeviceMetrics
- MoonLogLevel
- MoonMobileDevice
- MoonOptions
- NewSessionRequest
- NewSessionRequestCapabilities
- NewSessionResponse
- NewSessionResponseValue
- NewWindowRequest
- NewWindowResponse
- NewWindowResponseValue
- NullAction
- NullableStringResponse
- OperaOptions
- PerfLoggingPrefs
- PointerAction
- PreferenceValue
- PrintRequest
- PrintRequestOptions
- PrintRequestOptionsMargin
- PrintRequestOptionsPage
- Proxy
- Rect
- RectResponse
- ScriptRequest
- SelenoidOptions
- SendAlertTextRequest
- StatusResponse
- StatusResponseValue
- StringOrigin
- StringResponse
- SwitchToFrameRequest
- SwitchToWindowRequest
- Timeouts
- TimeoutsResponse
- UrlRequest
- WebElement
- WebElementOrigin
- WheelAction
Documentation For Authorization
BasicAuth
- Type: HTTP basic authentication
Example
auth := context.WithValue(context.Background(), sw.ContextBasicAuth, sw.BasicAuth{
UserName: "username",
Password: "password",
})
r, err := client.Service.Operation(auth, args)
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime