appiumgo

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 6 Imported by: 0

README

Appium Go Client

Appium Go客户端,从Python Appium客户端改写而来,使用[github.com/tebeka/selenium]作为底层WebDriver实现。

特性

  • 🚀 完整的Appium功能 - 支持所有主要的Appium功能和命令
  • 🔧 扩展系统 - 支持自定义扩展,类似Python版本的ExtensionBase
  • 📱 多平台支持 - 支持Android、iOS等平台
  • 高性能 - 基于Go语言的高性能实现
  • 🛡️ 类型安全 - 完全的类型安全,减少运行时错误
  • 🔗 直连支持 - 支持Appium的直连功能

安装

go mod init your-project
go get github.com/tebeka/selenium
go get github.com/google/uuid

快速开始

基本用法
package main

import (
    "fmt"
    "time"
    appium "path/to/appium-go"
)

func main() {
    // 创建Appium选项
    options := appium.NewAppiumOptions().
        SetPlatformName("Android").
        SetDeviceName("emulator-5554").
        SetApp("/path/to/your/app.apk").
        SetAutomationName("UIAutomator2")
    
    // 创建客户端配置
    clientConfig := appium.NewAppiumClientConfig("http://127.0.0.1:4723").
        WithTimeout(30 * time.Second).
        WithKeepAlive(true)
    
    // 创建WebDriver
    driver, err := appium.NewWebDriver("", options, clientConfig, nil)
    if err != nil {
        panic(err)
    }
    defer driver.Close()
    
    // 启动会话
    err = driver.StartSession(options.ToCapabilities())
    if err != nil {
        panic(err)
    }
    
    // 获取服务器状态
    status, err := driver.GetStatus()
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("服务器状态: %+v\n", status)
}
使用Applications扩展
package main

import (
    appium "path/to/appium-go"
)

func main() {
    // 创建driver(省略配置代码)
    options := appium.NewAppiumOptions().
        SetPlatformName("Android").
        SetDeviceName("emulator-5554").
        SetAutomationName("UIAutomator2")
    
    driver, err := appium.NewWebDriver("", options, nil, nil)
    if err != nil {
        panic(err)
    }
    defer driver.Close()
    
    // 创建Applications扩展
    apps := appium.NewApplications(driver)
    
    bundleID := "com.example.app"
    
    // 检查应用是否已安装
    installed, err := apps.IsAppInstalled(bundleID)
    if err != nil {
        panic(err)
    }
    
    if !installed {
        // 安装应用
        err = apps.InstallApp("/path/to/app.apk", map[string]interface{}{
            "replace": true,
        })
        if err != nil {
            panic(err)
        }
    }
    
    // 激活应用
    err = apps.ActivateApp(bundleID)
    if err != nil {
        panic(err)
    }
    
    // 将应用置于后台5秒
    err = apps.BackgroundApp(5)
    if err != nil {
        panic(err)
    }
    
    // 查询应用状态
    state, err := apps.QueryAppState(bundleID)
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("应用状态: %d\n", state)
}
创建自定义扩展
package main

import (
    appium "path/to/appium-go"
)

// 自定义扩展示例
type MyCustomExtension struct {
    appium.BaseExtension
}

func (ext *MyCustomExtension) MethodName() string {
    return "myCustomMethod"
}

func (ext *MyCustomExtension) AddCommand() (string, string) {
    return "GET", "session/$sessionId/my/custom/endpoint"
}

func (ext *MyCustomExtension) MyCustomMethod() (interface{}, error) {
    result, err := ext.Execute(nil)
    if err != nil {
        return nil, err
    }
    
    // 提取value字段(Appium响应格式)
    if resultMap, ok := result.(map[string]interface{}); ok {
        if value, exists := resultMap["value"]; exists {
            return value, nil
        }
    }
    
    return result, nil
}

func main() {
    // 创建自定义扩展
    customExt := &MyCustomExtension{}
    
    // 创建带有自定义扩展的driver
    options := appium.NewAppiumOptions().
        SetPlatformName("iOS").
        SetDeviceName("iPhone Simulator").
        SetAutomationName("XCUITest")
    
    driver, err := appium.NewWebDriver("", options, nil, []appium.ExtensionBase{customExt})
    if err != nil {
        panic(err)
    }
    defer driver.Close()
    
    // 使用自定义扩展方法
    result, err := customExt.MyCustomMethod()
    if err != nil {
        panic(err)
    }
    
    fmt.Printf("自定义扩展结果: %v\n", result)
}
使用直连功能
package main

import (
    appium "path/to/appium-go"
)

func main() {
    // 启用直连功能的客户端配置
    clientConfig := appium.NewAppiumClientConfig("http://127.0.0.1:4723").
        WithDirectConnection(true).
        WithKeepAlive(true)
    
    options := appium.NewAppiumOptions().
        SetPlatformName("Android").
        SetDeviceName("emulator-5554").
        SetAutomationName("UIAutomator2")
    
    driver, err := appium.NewWebDriver("", options, clientConfig, nil)
    if err != nil {
        panic(err)
    }
    defer driver.Close()
    
    // 启动会话 - 如果服务器支持,将使用直连
    err = driver.StartSession(options.ToCapabilities())
    if err != nil {
        panic(err)
    }
    
    fmt.Println("会话已启动,使用直连功能")
}

核心概念

AppiumOptions

AppiumOptions 类用于构建Appium capabilities,支持链式调用:

options := appium.NewAppiumOptions().
    SetPlatformName("Android").
    SetDeviceName("emulator-5554").
    SetApp("/path/to/app.apk").
    SetAutomationName("UIAutomator2").
    SetUDID("device-udid").
    SetNoReset(true).
    SetFullReset(false).
    SetNewCommandTimeout(60)
AppiumClientConfig

AppiumClientConfig 用于配置客户端行为:

clientConfig := appium.NewAppiumClientConfig("http://127.0.0.1:4723").
    WithDirectConnection(true).
    WithKeepAlive(true).
    WithTimeout(30 * time.Second).
    WithCapability("customCap", "value")
扩展系统

扩展系统允许你添加自定义功能,类似Python版本:

  1. 实现 ExtensionBase 接口
  2. 提供 MethodName()AddCommand() 方法
  3. 创建WebDriver时传入扩展
命令执行

所有Appium命令都通过 Execute 方法执行:

result, err := driver.Execute("getStatus", nil)

API 参考

WebDriver 方法
  • NewWebDriver(commandExecutor, options, clientConfig, extensions) - 创建新的WebDriver实例
  • StartSession(capabilities) - 启动新会话
  • GetStatus() - 获取服务器状态
  • GetOrientation() - 获取设备方向
  • SetOrientation(orientation) - 设置设备方向
  • Execute(command, params) - 执行命令
  • Close() - 关闭会话
Applications 方法
  • IsAppInstalled(bundleID) - 检查应用是否已安装
  • InstallApp(appPath, options) - 安装应用
  • RemoveApp(appID, options) - 卸载应用
  • ActivateApp(appID) - 激活应用
  • TerminateApp(appID, options) - 终止应用
  • BackgroundApp(seconds) - 将应用置于后台
  • QueryAppState(appID) - 查询应用状态
  • GetAppStrings(language, stringFile) - 获取应用字符串

与Python版本的对比

特性 Python Go
类型安全 运行时检查 编译时检查
性能 解释执行 编译执行
扩展系统 动态添加方法 接口实现
错误处理 异常 error返回值
并发 线程/协程 goroutine

注意事项

  1. 这是一个基础实现,某些高级功能可能需要进一步开发
  2. 需要配合Appium服务器使用
  3. 确保设备连接和配置正确
  4. 建议在测试环境中充分验证

贡献

欢迎提交PR和Issue!

许可证

Apache License 2.0

Documentation

Index

Constants

View Source
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"
)
View Source
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

View Source
const (
	// AppiumPrefix is the prefix for Appium-specific capabilities
	AppiumPrefix = "appium:"

	// PlatformName capability key
	PlatformName = "platformName"

	// BrowserName capability key
	BrowserName = "browserName"
)

Variables

View Source
var OSSToW3CConversion = map[string]string{
	"acceptSslCerts": "acceptInsecureCerts",
	"version":        "browserVersion",
	"platform":       PlatformName,
}

OSS to W3C capability conversion map

View Source
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

func AsW3C

func AsW3C(capabilities map[string]interface{}) map[string]interface{}

AsW3C formats capabilities to a valid W3C session request object

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

func (*ActionHelpers) Tap

func (ah *ActionHelpers) Tap(positions []Position, duration int) error

Tap taps on particular places with up to five fingers using selenium PerformActions

func (*ActionHelpers) Zoom

func (ah *ActionHelpers) Zoom(centerX, centerY, distance int, duration int) error

Zoom performs a zoom gesture (zoom in) 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

type AppiumConnection struct {
	selenium.WebDriver
	// contains filtered or unexported fields
}

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

type ExecuteFunc func(command string, params map[string]interface{}) (interface{}, error)

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 Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
}

Position represents a coordinate position

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

func (wd *WebDriver) AssertExtensionExists(extName string) error

AssertExtensionExists verifies if the given extension is not present in the list of absent extensions

func (*WebDriver) Close

func (wd *WebDriver) Close() error

Close closes the WebDriver session

func (*WebDriver) DeleteExtensions

func (wd *WebDriver) DeleteExtensions()

DeleteExtensions removes all extensions

func (*WebDriver) Execute

func (wd *WebDriver) Execute(command string, params map[string]interface{}) (interface{}, error)

Execute executes a command with the given parameters

func (*WebDriver) ExecuteScript

func (wd *WebDriver) ExecuteScript(script string, args map[string]interface{}) (interface{}, error)

ExecuteScript is a placeholder for script execution In a full implementation, this would call the WebDriver's ExecuteScript method

func (*WebDriver) GetCapabilities

func (wd *WebDriver) GetCapabilities() map[string]interface{}

GetCapabilities returns the current session capabilities

func (*WebDriver) GetOrientation

func (wd *WebDriver) GetOrientation() (string, error)

GetOrientation gets the current orientation of the device

func (*WebDriver) GetSessionID

func (wd *WebDriver) GetSessionID() string

GetSessionID returns the current session ID

func (*WebDriver) GetStatus

func (wd *WebDriver) GetStatus() (map[string]interface{}, error)

GetStatus gets the Appium server status

func (*WebDriver) MarkExtensionAbsence

func (wd *WebDriver) MarkExtensionAbsence(extName string) *WebDriver

MarkExtensionAbsence marks the given extension as absent

func (*WebDriver) SetOrientation

func (wd *WebDriver) SetOrientation(orientation string) error

SetOrientation sets the current orientation of the device

func (*WebDriver) StartSession

func (wd *WebDriver) StartSession(capabilities map[string]interface{}) error

StartSession creates a new session with the desired capabilities

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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