Documentation
¶
Index ¶
- Constants
- Variables
- func AsW3C(capabilities map[string]interface{}) map[string]interface{}
- type ActionHelpers
- func (ah *ActionHelpers) DragAndDrop(originEl, destinationEl selenium.WebElement, pause *float64) error
- func (ah *ActionHelpers) Flick(startX, startY, endX, endY int) error
- func (ah *ActionHelpers) LongPress(x, y int, duration int) error
- func (ah *ActionHelpers) LongPressElement(element selenium.WebElement, duration int) error
- func (ah *ActionHelpers) Pinch(centerX, centerY, distance int, duration int) error
- func (ah *ActionHelpers) Scroll(originEl, destinationEl selenium.WebElement, duration int) error
- func (ah *ActionHelpers) Swipe(startX, startY, endX, endY, duration int) error
- func (ah *ActionHelpers) Tap(positions []Position, duration int) error
- func (ah *ActionHelpers) Zoom(centerX, centerY, distance int, duration int) error
- type AppiumClientConfig
- func (c *AppiumClientConfig) GetDirectConnection() bool
- func (c *AppiumClientConfig) WithCapability(key string, value interface{}) *AppiumClientConfig
- func (c *AppiumClientConfig) WithDirectConnection(enable bool) *AppiumClientConfig
- func (c *AppiumClientConfig) WithKeepAlive(keepAlive bool) *AppiumClientConfig
- func (c *AppiumClientConfig) WithTimeout(timeout time.Duration) *AppiumClientConfig
- type AppiumConnection
- func (ac *AppiumConnection) Close() error
- func (ac *AppiumConnection) Execute(command string, params map[string]interface{}) (interface{}, error)
- func (ac *AppiumConnection) GetClientConfig() *AppiumClientConfig
- func (ac *AppiumConnection) GetRemoteConnectionHeaders(url string, keepAlive bool) map[string]string
- func (ac *AppiumConnection) SetHTTPClient(client *http.Client)
- type AppiumOptions
- func (opts *AppiumOptions) GetCapability(name string) interface{}
- func (opts *AppiumOptions) GetDefaultCapabilities() map[string]interface{}
- func (opts *AppiumOptions) LoadCapabilities(capabilities map[string]interface{}) *AppiumOptions
- func (opts *AppiumOptions) SetApp(app string) *AppiumOptions
- func (opts *AppiumOptions) SetAutomationName(automationName string) *AppiumOptions
- func (opts *AppiumOptions) SetCapability(name string, value interface{}) *AppiumOptions
- func (opts *AppiumOptions) SetDeviceName(deviceName string) *AppiumOptions
- func (opts *AppiumOptions) SetFullReset(fullReset bool) *AppiumOptions
- func (opts *AppiumOptions) SetNewCommandTimeout(timeout int) *AppiumOptions
- func (opts *AppiumOptions) SetNoReset(noReset bool) *AppiumOptions
- func (opts *AppiumOptions) SetPlatformName(platform string) *AppiumOptions
- func (opts *AppiumOptions) SetUDID(udid string) *AppiumOptions
- func (opts *AppiumOptions) ToCapabilities() map[string]interface{}
- func (opts *AppiumOptions) ToW3C() map[string]interface{}
- type Applications
- func (app *Applications) ActivateApp(appID string) error
- func (app *Applications) BackgroundApp(seconds int) error
- func (app *Applications) GetAppStrings(language string, stringFile string) (map[string]string, error)
- func (app *Applications) InstallApp(appPath string, options map[string]interface{}) error
- func (app *Applications) IsAppInstalled(bundleID string) (bool, error)
- func (app *Applications) QueryAppState(appID string) (int, error)
- func (app *Applications) RemoveApp(appID string, options map[string]interface{}) error
- func (app *Applications) TerminateApp(appID string, options map[string]interface{}) (bool, error)
- type BaseExtension
- type ExampleExtension
- type ExecuteFunc
- type ExtensionBase
- type ExtensionManager
- func (em *ExtensionManager) AddExtension(ext ExtensionBase)
- func (em *ExtensionManager) AssertExtensionExists(extName string) error
- func (em *ExtensionManager) DeleteExtensions()
- func (em *ExtensionManager) GetExtensions() []ExtensionBase
- func (em *ExtensionManager) MarkExtensionAbsence(extName string)
- type MobileCommand
- type MultiTouchAction
- type Position
- type TouchAction
- type WebDriver
- func (wd *WebDriver) AssertExtensionExists(extName string) error
- func (wd *WebDriver) Close() error
- func (wd *WebDriver) DeleteExtensions()
- func (wd *WebDriver) Execute(command string, params map[string]interface{}) (interface{}, error)
- func (wd *WebDriver) ExecuteScript(script string, args map[string]interface{}) (interface{}, error)
- func (wd *WebDriver) GetCapabilities() map[string]interface{}
- func (wd *WebDriver) GetOrientation() (string, error)
- func (wd *WebDriver) GetSessionID() string
- func (wd *WebDriver) GetStatus() (map[string]interface{}, error)
- func (wd *WebDriver) MarkExtensionAbsence(extName string) *WebDriver
- func (wd *WebDriver) SetOrientation(orientation string) error
- func (wd *WebDriver) StartSession(capabilities map[string]interface{}) error
Constants ¶
const ( // PrefixHeader is the user agent prefix for Appium PrefixHeader = "appium/" // HeaderIdempotencyKey is the header for idempotency HeaderIdempotencyKey = "X-Idempotency-Key" // Version represents the library version Version = "1.0.0" )
const ( GetSession = "getSession" GetStatus = "getStatus" // MJSONWP for Selenium v4 GetLocation = "getLocation" SetLocation = "setLocation" Clear = "clear" LocationInView = "locationInView" Contexts = "getContexts" GetCurrentContext = "getCurrentContext" SwitchToContext = "switchToContext" Background = "background" GetAppStrings = "getAppStrings" IsLocked = "isLocked" Lock = "lock" Unlock = "unlock" GetDeviceTimeGet = "getDeviceTimeGet" GetDeviceTimePost = "getDeviceTimePost" InstallApp = "installApp" RemoveApp = "removeApp" IsAppInstalled = "isAppInstalled" TerminateApp = "terminateApp" ActivateApp = "activateApp" QueryAppState = "queryAppState" Shake = "shake" HideKeyboard = "hideKeyboard" PressKeycode = "pressKeyCode" LongPressKeycode = "longPressKeyCode" KeyEvent = "keyEvent" // Needed for Selendroid PushFile = "pushFile" PullFile = "pullFile" PullFolder = "pullFolder" GetClipboard = "getClipboard" SetClipboard = "setClipboard" FingerPrint = "fingerPrint" GetSettings = "getSettings" UpdateSettings = "updateSettings" StartRecordingScreen = "startRecordingScreen" StopRecordingScreen = "stopRecordingScreen" CompareImages = "compareImages" IsKeyboardShown = "isKeyboardShown" ExecuteDriver = "executeDriver" GetEvents = "getLogEvents" LogEvent = "logCustomEvent" // MJSONWP for Selenium v4 IsElementDisplayed = "isElementDisplayed" GetCapabilities = "getCapabilities" GetScreenOrientation = "getScreenOrientation" SetScreenOrientation = "setScreenOrientation" // To override selenium commands GetLog = "getLog" GetAvailableLogTypes = "getAvailableLogTypes" // Android OpenNotifications = "openNotifications" GetCurrentActivity = "getCurrentActivity" GetCurrentPackage = "getCurrentPackage" GetSystemBars = "getSystemBars" GetDisplayDensity = "getDisplayDensity" ToggleWifi = "toggleWiFi" ToggleLocationServices = "toggleLocationServices" GetPerformanceDataTypes = "getPerformanceDataTypes" GetPerformanceData = "getPerformanceData" GetNetworkConnection = "getNetworkConnection" SetNetworkConnection = "setNetworkConnection" // Android Emulator SendSMS = "sendSms" MakeGSMCall = "makeGsmCall" SetGSMSignal = "setGsmSignal" SetGSMVoice = "setGsmVoice" SetNetworkSpeed = "setNetworkSpeed" SetPowerCapacity = "setPowerCapacity" SetPowerAC = "setPowerAc" // iOS TouchID = "touchId" ToggleTouchIDEnrollment = "toggleTouchIdEnrollment" )
Common commands
const ( // AppiumPrefix is the prefix for Appium-specific capabilities AppiumPrefix = "appium:" // PlatformName capability key PlatformName = "platformName" // BrowserName capability key BrowserName = "browserName" )
Variables ¶
var OSSToW3CConversion = map[string]string{ "acceptSslCerts": "acceptInsecureCerts", "version": "browserVersion", "platform": PlatformName, }
OSS to W3C capability conversion map
var W3CCapabilityNames = map[string]bool{ "acceptInsecureCerts": true, BrowserName: true, "browserVersion": true, PlatformName: true, "pageLoadStrategy": true, "proxy": true, "setWindowRect": true, "timeouts": true, "unhandledPromptBehavior": true, }
W3C capability names that don't need the appium prefix
Functions ¶
Types ¶
type ActionHelpers ¶
type ActionHelpers struct {
// contains filtered or unexported fields
}
ActionHelpers provides touch action functionality for Appium WebDriver
func NewActionHelpers ¶
func NewActionHelpers(driver *WebDriver) *ActionHelpers
NewActionHelpers creates a new ActionHelpers instance
func (*ActionHelpers) DragAndDrop ¶
func (ah *ActionHelpers) DragAndDrop(originEl, destinationEl selenium.WebElement, pause *float64) error
DragAndDrop drags the origin element to the destination element using selenium PerformActions
func (*ActionHelpers) Flick ¶
func (ah *ActionHelpers) Flick(startX, startY, endX, endY int) error
Flick flicks from one point to another point using selenium PerformActions
func (*ActionHelpers) LongPress ¶
func (ah *ActionHelpers) LongPress(x, y int, duration int) error
LongPress performs a long press on the specified coordinates using selenium PerformActions
func (*ActionHelpers) LongPressElement ¶
func (ah *ActionHelpers) LongPressElement(element selenium.WebElement, duration int) error
LongPressElement performs a long press on the specified element using selenium PerformActions
func (*ActionHelpers) Pinch ¶
func (ah *ActionHelpers) Pinch(centerX, centerY, distance int, duration int) error
Pinch performs a pinch gesture (zoom out) using selenium PerformActions
func (*ActionHelpers) Scroll ¶
func (ah *ActionHelpers) Scroll(originEl, destinationEl selenium.WebElement, duration int) error
Scroll scrolls from one element to another using selenium PerformActions
func (*ActionHelpers) Swipe ¶
func (ah *ActionHelpers) Swipe(startX, startY, endX, endY, duration int) error
Swipe swipes from one point to another point using selenium PerformActions
type AppiumClientConfig ¶
type AppiumClientConfig struct {
// RemoteServerAddr is the address of the Appium server
RemoteServerAddr string
// DirectConnection enables directConnect feature
// https://github.com/appium/python-client?tab=readme-ov-file#direct-connect-urls
DirectConnection bool
// KeepAlive controls HTTP keep-alive
KeepAlive bool
// Timeout for HTTP requests
Timeout time.Duration
// Additional capabilities
Capabilities selenium.Capabilities
}
AppiumClientConfig contains configuration for Appium client This struct extends functionality similar to selenium ClientConfig
func NewAppiumClientConfig ¶
func NewAppiumClientConfig(remoteServerAddr string) *AppiumClientConfig
NewAppiumClientConfig creates a new AppiumClientConfig with default values
func (*AppiumClientConfig) GetDirectConnection ¶
func (c *AppiumClientConfig) GetDirectConnection() bool
GetDirectConnection returns whether directConnect is enabled
func (*AppiumClientConfig) WithCapability ¶
func (c *AppiumClientConfig) WithCapability(key string, value interface{}) *AppiumClientConfig
WithCapability adds a capability
func (*AppiumClientConfig) WithDirectConnection ¶
func (c *AppiumClientConfig) WithDirectConnection(enable bool) *AppiumClientConfig
WithDirectConnection enables direct connection feature
func (*AppiumClientConfig) WithKeepAlive ¶
func (c *AppiumClientConfig) WithKeepAlive(keepAlive bool) *AppiumClientConfig
WithKeepAlive sets the keep-alive setting
func (*AppiumClientConfig) WithTimeout ¶
func (c *AppiumClientConfig) WithTimeout(timeout time.Duration) *AppiumClientConfig
WithTimeout sets the HTTP timeout
type AppiumConnection ¶
AppiumConnection wraps selenium.Remote with Appium-specific functionality
func NewAppiumConnection ¶
func NewAppiumConnection(clientConfig *AppiumClientConfig) (*AppiumConnection, error)
NewAppiumConnection creates a new Appium connection
func (*AppiumConnection) Close ¶
func (ac *AppiumConnection) Close() error
Close closes the connection
func (*AppiumConnection) Execute ¶
func (ac *AppiumConnection) Execute(command string, params map[string]interface{}) (interface{}, error)
Execute executes a command with the given parameters
func (*AppiumConnection) GetClientConfig ¶
func (ac *AppiumConnection) GetClientConfig() *AppiumClientConfig
GetClientConfig returns the client configuration
func (*AppiumConnection) GetRemoteConnectionHeaders ¶
func (ac *AppiumConnection) GetRemoteConnectionHeaders(url string, keepAlive bool) map[string]string
GetRemoteConnectionHeaders returns headers for remote connection This method mimics the Python implementation for controlling extra headers
func (*AppiumConnection) SetHTTPClient ¶
func (ac *AppiumConnection) SetHTTPClient(client *http.Client)
SetHTTPClient allows setting a custom HTTP client
type AppiumOptions ¶
type AppiumOptions struct {
// contains filtered or unexported fields
}
AppiumOptions represents Appium capabilities and options
func NewAppiumOptions ¶
func NewAppiumOptions() *AppiumOptions
NewAppiumOptions creates a new AppiumOptions instance
func (*AppiumOptions) GetCapability ¶
func (opts *AppiumOptions) GetCapability(name string) interface{}
GetCapability fetches a capability value or nil if not set
func (*AppiumOptions) GetDefaultCapabilities ¶
func (opts *AppiumOptions) GetDefaultCapabilities() map[string]interface{}
GetDefaultCapabilities returns default capabilities
func (*AppiumOptions) LoadCapabilities ¶
func (opts *AppiumOptions) LoadCapabilities(capabilities map[string]interface{}) *AppiumOptions
LoadCapabilities sets multiple capabilities
func (*AppiumOptions) SetApp ¶
func (opts *AppiumOptions) SetApp(app string) *AppiumOptions
SetApp sets the app capability
func (*AppiumOptions) SetAutomationName ¶
func (opts *AppiumOptions) SetAutomationName(automationName string) *AppiumOptions
SetAutomationName sets the automation name capability
func (*AppiumOptions) SetCapability ¶
func (opts *AppiumOptions) SetCapability(name string, value interface{}) *AppiumOptions
SetCapability sets a capability value
func (*AppiumOptions) SetDeviceName ¶
func (opts *AppiumOptions) SetDeviceName(deviceName string) *AppiumOptions
SetDeviceName sets the device name capability
func (*AppiumOptions) SetFullReset ¶
func (opts *AppiumOptions) SetFullReset(fullReset bool) *AppiumOptions
SetFullReset sets the fullReset capability
func (*AppiumOptions) SetNewCommandTimeout ¶
func (opts *AppiumOptions) SetNewCommandTimeout(timeout int) *AppiumOptions
SetNewCommandTimeout sets the newCommandTimeout capability
func (*AppiumOptions) SetNoReset ¶
func (opts *AppiumOptions) SetNoReset(noReset bool) *AppiumOptions
SetNoReset sets the noReset capability
func (*AppiumOptions) SetPlatformName ¶
func (opts *AppiumOptions) SetPlatformName(platform string) *AppiumOptions
SetPlatformName sets the platform name capability
func (*AppiumOptions) SetUDID ¶
func (opts *AppiumOptions) SetUDID(udid string) *AppiumOptions
SetUDID sets the UDID capability
func (*AppiumOptions) ToCapabilities ¶
func (opts *AppiumOptions) ToCapabilities() map[string]interface{}
ToCapabilities returns a copy of the capabilities
func (*AppiumOptions) ToW3C ¶
func (opts *AppiumOptions) ToW3C() map[string]interface{}
ToW3C formats the instance to a valid W3C session request object
type Applications ¶
type Applications struct {
// contains filtered or unexported fields
}
Applications provides application management functionality This corresponds to the Python Applications extension
func NewApplications ¶
func NewApplications(wd *WebDriver) *Applications
NewApplications creates a new Applications extension
func (*Applications) ActivateApp ¶
func (app *Applications) ActivateApp(appID string) error
ActivateApp activates the application if it is not running or is running in the background
func (*Applications) BackgroundApp ¶
func (app *Applications) BackgroundApp(seconds int) error
BackgroundApp puts the application in the background on the device for a certain duration
func (*Applications) GetAppStrings ¶
func (app *Applications) GetAppStrings(language string, stringFile string) (map[string]string, error)
GetAppStrings returns the application strings from the device for the specified language
func (*Applications) InstallApp ¶
func (app *Applications) InstallApp(appPath string, options map[string]interface{}) error
InstallApp installs the application found at appPath on the device
func (*Applications) IsAppInstalled ¶
func (app *Applications) IsAppInstalled(bundleID string) (bool, error)
IsAppInstalled checks whether the application specified by bundleID is installed on the device
func (*Applications) QueryAppState ¶
func (app *Applications) QueryAppState(appID string) (int, error)
QueryAppState queries the state of the application
func (*Applications) RemoveApp ¶
func (app *Applications) RemoveApp(appID string, options map[string]interface{}) error
RemoveApp removes the specified application from the device
func (*Applications) TerminateApp ¶
func (app *Applications) TerminateApp(appID string, options map[string]interface{}) (bool, error)
TerminateApp terminates the application if it is running
type BaseExtension ¶
type BaseExtension struct {
// contains filtered or unexported fields
}
BaseExtension provides a default implementation of ExtensionBase
func (*BaseExtension) AddCommand ¶
func (be *BaseExtension) AddCommand() (string, string)
AddCommand must be implemented by concrete extensions
func (*BaseExtension) Execute ¶
func (be *BaseExtension) Execute(parameters map[string]interface{}) (interface{}, error)
Execute executes the command with optional parameters
func (*BaseExtension) MethodName ¶
func (be *BaseExtension) MethodName() string
MethodName must be implemented by concrete extensions
func (*BaseExtension) SetExecuteFunc ¶
func (be *BaseExtension) SetExecuteFunc(execute ExecuteFunc)
SetExecuteFunc sets the execute function
type ExampleExtension ¶
type ExampleExtension struct {
BaseExtension
}
Example custom extension implementation
func (*ExampleExtension) AddCommand ¶
func (ee *ExampleExtension) AddCommand() (string, string)
AddCommand returns the HTTP method and URL for this extension
func (*ExampleExtension) CustomMethodName ¶
func (ee *ExampleExtension) CustomMethodName() (interface{}, error)
CustomMethodName is the actual method that will be called
func (*ExampleExtension) MethodName ¶
func (ee *ExampleExtension) MethodName() string
MethodName returns the method name for this extension
type ExecuteFunc ¶
ExecuteFunc represents a function that can execute commands
type ExtensionBase ¶
type ExtensionBase interface {
// MethodName returns the method name that will be available on the driver
MethodName() string
// AddCommand returns the HTTP method and URL for the command
AddCommand() (string, string)
// SetExecuteFunc sets the execute function for this extension
SetExecuteFunc(execute ExecuteFunc)
}
ExtensionBase provides the base functionality for creating custom extensions This mimics the Python ExtensionBase class functionality
type ExtensionManager ¶
type ExtensionManager struct {
// contains filtered or unexported fields
}
Extension manager handles extensions for the WebDriver
func NewExtensionManager ¶
func NewExtensionManager() *ExtensionManager
NewExtensionManager creates a new extension manager
func (*ExtensionManager) AddExtension ¶
func (em *ExtensionManager) AddExtension(ext ExtensionBase)
AddExtension adds an extension to the manager
func (*ExtensionManager) AssertExtensionExists ¶
func (em *ExtensionManager) AssertExtensionExists(extName string) error
AssertExtensionExists verifies if the given extension is not in the absent list
func (*ExtensionManager) DeleteExtensions ¶
func (em *ExtensionManager) DeleteExtensions()
DeleteExtensions removes all extensions (for cleanup)
func (*ExtensionManager) GetExtensions ¶
func (em *ExtensionManager) GetExtensions() []ExtensionBase
GetExtensions returns all registered extensions
func (*ExtensionManager) MarkExtensionAbsence ¶
func (em *ExtensionManager) MarkExtensionAbsence(extName string)
MarkExtensionAbsence marks the given extension as absent
type MobileCommand ¶
type MobileCommand struct{}
MobileCommand contains Appium-specific command constants
type MultiTouchAction ¶
type MultiTouchAction struct {
Actions [][]TouchAction `json:"actions"`
}
type TouchAction ¶
type TouchAction struct {
Action string `json:"action"`
Options map[string]interface{} `json:"options,omitempty"`
Element string `json:"element,omitempty"`
X *int `json:"x,omitempty"`
Y *int `json:"y,omitempty"`
Duration *int `json:"ms,omitempty"`
}
Legacy TouchAction support for backward compatibility
type WebDriver ¶
type WebDriver struct {
selenium.WebDriver
*ActionHelpers
*Applications
// contains filtered or unexported fields
}
WebDriver represents an Appium WebDriver instance This is the main class that corresponds to Python's WebDriver class
func NewWebDriver ¶
func NewWebDriver(commandExecutor string, options *AppiumOptions, clientConfig *AppiumClientConfig, extensions []ExtensionBase) (*WebDriver, error)
NewWebDriver creates a new Appium WebDriver instance
func (*WebDriver) AssertExtensionExists ¶
AssertExtensionExists verifies if the given extension is not present in the list of absent extensions
func (*WebDriver) DeleteExtensions ¶
func (wd *WebDriver) DeleteExtensions()
DeleteExtensions removes all extensions
func (*WebDriver) ExecuteScript ¶
ExecuteScript is a placeholder for script execution In a full implementation, this would call the WebDriver's ExecuteScript method
func (*WebDriver) GetCapabilities ¶
GetCapabilities returns the current session capabilities
func (*WebDriver) GetOrientation ¶
GetOrientation gets the current orientation of the device
func (*WebDriver) GetSessionID ¶
GetSessionID returns the current session ID
func (*WebDriver) MarkExtensionAbsence ¶
MarkExtensionAbsence marks the given extension as absent
func (*WebDriver) SetOrientation ¶
SetOrientation sets the current orientation of the device
func (*WebDriver) StartSession ¶
StartSession creates a new session with the desired capabilities