WebDriverAgent ( iOS ) Client Library in Golang

Overview

Golang-WDA

go doc go report license

appium/WebDriverAgent Client Library in Golang

Android can use electricbubble/guia2

中文 README

Installation

First, install WebDriverAgent for iOS devices

go get github.com/electricbubble/gwda

Connection Device

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)

	// 需要 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

Issues
  • src/github.com/electricbubble/gidevice/pkg/ipa/ipa.go:35:17: undefined: io.ReadAll

    src/github.com/electricbubble/gidevice/pkg/ipa/ipa.go:35:17: undefined: io.ReadAll

    我的代码是这样的

    	driver, err := gwda.NewUSBDriver(nil)
    	if err != nil {
    		log.Fatalln(err)
    	}
    
    	log.Println(driver.IsWdaHealthy())
    

    但运行时报了个这个错

    
    src/github.com/electricbubble/gidevice/pkg/ipa/ipa.go:35:17: undefined: io.ReadAll
    
    
    opened by RokcyX 4
  • 解析截图失败

    解析截图失败

    版本:

    • webdriveragent-xcode_12.3.zip v2.32.2
    • github.com/electricbubble/gwda v0.1.1
    • iOS 13.4.1
    bs, err := driver.Screenshot()
    session, _ := driver.ActiveSession()
    t.Log(session.SessionId)
    if nil != err {
    	t.Error("screenshot", err)
    } else {
    	// dst := base64.StdEncoding.EncodeToString(bs.Bytes())
    	// t.Log(dst)
    	img, format, err := image.Decode(bs)
    	if nil != err {
    		t.Error("decode", err) // image: unknown format <===
    	} else {
    		t.Log(bs.Len(), img, format)
    	}
    }
    

    经浏览器直接请求截图看到,返回的图片 base64 是带有 \r\n 换行符的,是否因这个问题解析失败呢?

    如下图所示:

    235434.png

    opened by zhanglianxin 3
  • go get错误,建议增加相应的安装说明

    go get错误,建议增加相应的安装说明

    $ go get -v github.com/ElectricBubble/gwda
    go: finding github.com/ElectricBubble/gwda latest
    go: downloading github.com/ElectricBubble/gwda v0.0.0-20200511015801-0e9736d3712a
    go: extracting github.com/ElectricBubble/gwda v0.0.0-20200511015801-0e9736d3712a
    go get: github.com/ElectricBubble/[email protected]: parsing go.mod:
    	module declares its path as: github.com/electricbubble/gwda
    	        but was required as: github.com/ElectricBubble/gwda
    
    opened by codeskyblue 3
  • How does USBDriver work?

    How does USBDriver work?

    I found this code in NewUSBDriver

    if wd.urlPrefix, err = url.Parse("http://" + dev.serialNumber); err != nil {
    		return nil, err
    }
    

    but why http://xxxxxx can work in code?

    opened by ZhouYixun 2
  • add a helper function to get initialized giDevice.Device from gwda.Device

    add a helper function to get initialized giDevice.Device from gwda.Device

    • feat: get initialized giDevice.Device from gwda.Device
    • change: upgrade gidevice to v0.6.2
    • fix: go lint warnings

    examples:

    d := &gwda.Device{}
    
    d.GIDevice().AppLaunch("com.apple.springboard")
    d.GIDevice().Screenshot()
    
    opened by debugtalk 0
Owner
雷系泡泡
雷系泡泡
Golang HTTP client testing framework

flute Golang HTTP client testing framework Presentation https://speakerdeck.com/szksh/flute-golang-http-client-testing-framework Overview flute is the

Shunsuke Suzuki 17 Apr 19, 2022
go websocket client for unit testing of a websocket handler

wstest A websocket client for unit-testing a websocket server The gorilla organization provides full featured websocket implementation that the standa

Eyal Posener 92 Aug 2, 2022
A basic lightweight HTTP client for Go with included mock features.

A basic lightweight HTTP client for Go with included mock features. Features Support almost all http method like G

Andres Mijares 1 May 2, 2022
Test TiDB with multiple client versions

Usage Put multiple client versions in ~/opt/mysql/<version>/bin/mysql. If you are using dbdeployer you might already have this. Recommended set of ver

Daniël van Eeden 0 Nov 16, 2021
mock server to aid testing the jaguar-java client API

stripe-mock stripe-mock is a mock HTTP server that responds like the real Stripe API. It can be used instead of Stripe's test mode to make test suites

knr.data 1 Dec 24, 2021
Client tool for testing HTTP server timeouts

HTTP timeout test client While testing Go HTTP server timeouts I wrote this little tool to help me test. It allows for slowing down header write and b

Adam Pritchard 7 May 11, 2022
Fortio load testing library, command line tool, advanced echo server and web UI in go (golang). Allows to specify a set query-per-second load and record latency histograms and other useful stats.

Fortio Fortio (Φορτίο) started as, and is, Istio's load testing tool and now graduated to be its own project. Fortio is also used by, among others, Me

Fortio (Φορτίο) 2.6k Jul 28, 2022
A library to aid unittesting code that uses Golang's Github SDK

go-github-mock A library to aid unittesting code that uses Golang's Github SDK Installation go get github.com/migueleliasweb/go-github-mock Features C

Miguel Elias dos Santos 41 Jul 26, 2022
Gostresslib - A golang library for stress testing.

GoStressLib A golang library for stress testing. Install go get github.com/tenhan/gostresslib Usage package main import ( "github.com/tenhan/gostres

null 0 Jan 13, 2022
A yaml data-driven testing format together with golang testing library

Specimen Yaml-based data-driven testing Specimen is a yaml data format for data-driven testing. This enforces separation between feature being tested

Design it, Run it 0 Jan 31, 2022
Random - A Golang library that provides functions for generating random values

Random A Golang library that provides functions for generating random values. Us

Fatih Cetinkaya 1 Apr 14, 2022
:exclamation:Basic Assertion Library used along side native go testing, with building blocks for custom assertions

Package assert Package assert is a Basic Assertion library used along side native go testing Installation Use go get. go get github.com/go-playground/

Go Playgound 41 Aug 4, 2022
Library created for testing JSON against patterns.

Gomatch Library created for testing JSON against patterns. The goal was to be able to validate JSON focusing only on parts essential in given test cas

null 42 Jul 24, 2022
A BDD library for Go

gospecify This provides a BDD syntax for testing your Go code. It should be familiar to anybody who has used libraries such as rspec. Installation The

Samuel Tesla 52 Nov 22, 2021
A Go test assertion library for verifying that two representations of JSON are semantically equal

jsonassert is a Go test assertion library for verifying that two representations of JSON are semantically equal. Usage Create a new *jsonassert.Assert

Roger Guldbrandsen 86 Jul 16, 2022
A Go library help testing your RESTful API application

RESTit A Go micro-framework to help writing RESTful API integration test Package RESTit provides helps to those who want to write an integration test

RESTit 55 Nov 25, 2021
testcase is an opinionated behavior-driven-testing library

Table of Contents testcase Guide Official API Documentation Getting Started / Example Modules Summary DRY Modularization Stability Case Study About te

Adam Luzsi 94 Jul 20, 2022
A toolkit with common assertions and mocks that plays nicely with the standard library

Testify - Thou Shalt Write Tests ℹ️ We are working on testify v2 and would love to hear what you'd like to see in it, have your say here: https://cutt

Stretchr, Inc. 17.2k Aug 1, 2022
Playwright for Go a browser automation library to control Chromium, Firefox and WebKit with a single API.

?? Playwright for API reference | Example recipes Playwright is a Go library to automate Chromium, Firefox and WebKit with a single API. Playwright is

Max Schmitt 876 Aug 2, 2022