MCPcopy Index your code
hub / github.com/electricbubble/gwda

github.com/electricbubble/gwda @0.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release 0.5.0 ↗ · + Follow
488 symbols 1,165 edges 17 files 106 documented · 22% updated 2y ago★ 3176 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Golang-WDA

go doc go report license

appium/WebDriverAgent Client Library in Golang

Android can use electricbubble/guia2

English | 🇨🇳中文

Installation

First, install WebDriverAgent for iOS devices

```shell script go get github.com/electricbubble/gwda


## QuickStart

#### [Connection Device](examples/connect/main.go)

```go
package main

import (
    "github.com/electricbubble/gwda"
    "log"
)

func main() {
    // var urlPrefix = "http://localhost:8100"
    // The function may also require 'iproxy 8100 8100' to forward the device port first
    // driver, _ := gwda.NewDriver(nil, urlPrefix)

    // Connect devices via USB
    driver, _ := gwda.NewUSBDriver(nil)

    log.Println(driver.IsWdaHealthy())
}

Touch

package main

import (
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    x, y := 50, 256

    driver.Tap(x, y)

    driver.DoubleTap(x, y)

    driver.TouchAndHold(x, y)

    fromX, fromY, toX, toY := 50, 256, 100, 256

    driver.Drag(fromX, fromY, toX, toY)

    driver.Swipe(fromX, fromY, toX, toY)

    // requires hardware support: 3D Touch 
    // driver.ForceTouch(x, y, 0.8)
}

AssistiveTouch driver.PerformW3CActions driver.PerformAppiumTouchActions

App Actions

package main

import (
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    var bundleId = "com.apple.Preferences"

    driver.AppLaunchUnattached(bundleId)

    driver.AppDeactivate(2)

    driver.AppTerminate(bundleId)

    driver.AppActivate(bundleId)

    // Resets the 📷 camera authorization status of the current application
    // driver.AppAuthReset(gwda.ProtectedResourceCamera)
}

Keyboard

package main

import (
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    driver.SendKeys("hello")
}

specified element element.SendKeys

Siri

package main

import (
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    driver.SiriActivate("What's the weather like today")
}

Alert

package main

import (
    "github.com/electricbubble/gwda"
    "log"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    text, _ := driver.AlertText()
    log.Println(text)

    alertButtons, _ := driver.AlertButtons()
    log.Println(alertButtons)

    driver.AlertAccept()
    // driver.AlertDismiss()

    // driver.SendKeys("ah")
}

Device information

package main

import (
    "github.com/electricbubble/gwda"
    "log"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    deviceInfo, _ := driver.DeviceInfo()
    log.Println(deviceInfo.Name)

    batteryInfo, _ := driver.BatteryInfo()
    log.Println(batteryInfo.State)

    windowSize, _ := driver.WindowSize()
    log.Println(windowSize)

    location, err := driver.Location()
    if err != nil {
        log.Fatalln(err)
    }
    log.Println(location)

    // screen, _ := driver.Screen()
    // log.Println(screen)
}

Hardware button

package main

import (
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    // driver.Homescreen()

    driver.PressButton(gwda.DeviceButtonHome)
    driver.PressButton(gwda.DeviceButtonVolumeUp)
    driver.PressButton(gwda.DeviceButtonVolumeDown)
}

Screenshot

package main

import (
    "github.com/electricbubble/gwda"
    "image"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    screenshot, _ := driver.Screenshot()

    img, format, _ := image.Decode(screenshot)
    _, _ = img, format
}

Debug

package main

import (
    "fmt"
    "github.com/electricbubble/gwda"
)

func main() {
    driver, _ := gwda.NewUSBDriver(nil)

    source, _ := driver.Source()
    fmt.Println(source)

    // fmt.Println(driver.AccessibleSource())

    // gwda.SetDebug(true)
}

Extensions

About
electricbubble/gwda-ext-opencv Operate with pictures

Alternatives

About
openatx/facebook-wda Facebook WebDriverAgent Python Client Library (not official)

Thanks

Thank you JetBrains for providing free open source licenses

Extension points exported contracts — how you extend this code

WebDriver (Interface)
WebDriver defines methods supported by WebDriver drivers. [1 implementers]
gwda.go
DeviceOption (FuncType)
(no doc)
device.go
WebElement (Interface)
WebElement defines method supported by web elements. [1 implementers]
gwda.go
Condition (FuncType)
(no doc)
gwda.go

Core symbols most depended-on inside this repo

executePost
called by 52
driver.go
executeGet
called by 32
driver.go
SetDebug
called by 13
gwda.go
Pause
called by 13
action.go
NewUSBDriver
called by 12
driver.go
NewFingerMove
called by 11
action.go
WithOrigin
called by 11
action.go
Move
called by 11
action.go

Shape

Method 313
Function 128
TypeAlias 25
Struct 18
FuncType 2
Interface 2

Languages

Go100%

Modules by API surface

gwda.go200 symbols
driver.go79 symbols
driver_test.go63 symbols
action.go54 symbols
element.go42 symbols
element_test.go30 symbols
device.go10 symbols
examples/touch/main.go1 symbols
examples/siri/main.go1 symbols
examples/screenshot/main.go1 symbols
examples/keyboard/main.go1 symbols
examples/info/main.go1 symbols

For agents

$ claude mcp add gwda \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page