mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-01 22:09:35 +08:00
fix: specify uia2 ip and port
This commit is contained in:
@@ -7,6 +7,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type DeviceFileInfo struct {
|
type DeviceFileInfo struct {
|
||||||
@@ -20,7 +22,7 @@ func (info DeviceFileInfo) IsDir() bool {
|
|||||||
return (info.Mode & (1 << 14)) == (1 << 14)
|
return (info.Mode & (1 << 14)) == (1 << 14)
|
||||||
}
|
}
|
||||||
|
|
||||||
const DefaultFileMode = os.FileMode(0664)
|
const DefaultFileMode = os.FileMode(0o664)
|
||||||
|
|
||||||
type DeviceState string
|
type DeviceState string
|
||||||
|
|
||||||
@@ -147,6 +149,9 @@ func (d Device) RunShellCommandWithBytes(cmd string, args ...string) ([]byte, er
|
|||||||
if strings.TrimSpace(cmd) == "" {
|
if strings.TrimSpace(cmd) == "" {
|
||||||
return nil, errors.New("adb shell: command cannot be empty")
|
return nil, errors.New("adb shell: command cannot be empty")
|
||||||
}
|
}
|
||||||
|
log.Debug().Str("cmd",
|
||||||
|
fmt.Sprintf("adb -s %s shell %s", d.serial, cmd)).
|
||||||
|
Msg("run adb command")
|
||||||
raw, err := d.executeCommand(fmt.Sprintf("shell:%s", cmd))
|
raw, err := d.executeCommand(fmt.Sprintf("shell:%s", cmd))
|
||||||
return raw, err
|
return raw, err
|
||||||
}
|
}
|
||||||
@@ -156,6 +161,9 @@ func (d Device) EnableAdbOverTCP(port ...int) (err error) {
|
|||||||
port = []int{AdbDaemonPort}
|
port = []int{AdbDaemonPort}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Info().Str("cmd",
|
||||||
|
fmt.Sprintf("adb -s %s tcpip %d", d.serial, port[0])).
|
||||||
|
Msg("enable adb over tcp")
|
||||||
_, err = d.executeCommand(fmt.Sprintf("tcpip:%d", port[0]), true)
|
_, err = d.executeCommand(fmt.Sprintf("tcpip:%d", port[0]), true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,6 @@ func newTransport(address string, readTimeout ...time.Duration) (tp transport, e
|
|||||||
|
|
||||||
func (t transport) Send(command string) (err error) {
|
func (t transport) Send(command string) (err error) {
|
||||||
msg := fmt.Sprintf("%04x%s", len(command), command)
|
msg := fmt.Sprintf("%04x%s", len(command), command)
|
||||||
log.Debug().Str("cmd", command).Msg("run adb command")
|
|
||||||
return _send(t.sock, []byte(msg))
|
return _send(t.sock, []byte(msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
AdbServerHost = "localhost"
|
AdbServerHost = "localhost"
|
||||||
AdbServerPort = gadb.AdbServerPort // 5037
|
AdbServerPort = gadb.AdbServerPort // 5037
|
||||||
|
UIA2ServerHost = "localhost"
|
||||||
UIA2ServerPort = 6790
|
UIA2ServerPort = 6790
|
||||||
DeviceTempPath = "/data/local/tmp"
|
DeviceTempPath = "/data/local/tmp"
|
||||||
)
|
)
|
||||||
@@ -34,15 +35,15 @@ func WithSerialNumber(serial string) AndroidDeviceOption {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithAdbIP(ip string) AndroidDeviceOption {
|
func WithUIA2IP(ip string) AndroidDeviceOption {
|
||||||
return func(device *AndroidDevice) {
|
return func(device *AndroidDevice) {
|
||||||
device.IP = ip
|
device.UIA2IP = ip
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func WithAdbPort(port int) AndroidDeviceOption {
|
func WithUIA2Port(port int) AndroidDeviceOption {
|
||||||
return func(device *AndroidDevice) {
|
return func(device *AndroidDevice) {
|
||||||
device.Port = port
|
device.UIA2Port = port
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,11 +57,11 @@ func GetAndroidDeviceOptions(dev *AndroidDevice) (deviceOptions []AndroidDeviceO
|
|||||||
if dev.SerialNumber != "" {
|
if dev.SerialNumber != "" {
|
||||||
deviceOptions = append(deviceOptions, WithSerialNumber(dev.SerialNumber))
|
deviceOptions = append(deviceOptions, WithSerialNumber(dev.SerialNumber))
|
||||||
}
|
}
|
||||||
if dev.IP != "" {
|
if dev.UIA2IP != "" {
|
||||||
deviceOptions = append(deviceOptions, WithAdbIP(dev.IP))
|
deviceOptions = append(deviceOptions, WithUIA2IP(dev.UIA2IP))
|
||||||
}
|
}
|
||||||
if dev.Port != 0 {
|
if dev.UIA2Port != 0 {
|
||||||
deviceOptions = append(deviceOptions, WithAdbPort(dev.Port))
|
deviceOptions = append(deviceOptions, WithUIA2Port(dev.UIA2Port))
|
||||||
}
|
}
|
||||||
if dev.LogOn {
|
if dev.LogOn {
|
||||||
deviceOptions = append(deviceOptions, WithAdbLogOn(true))
|
deviceOptions = append(deviceOptions, WithAdbLogOn(true))
|
||||||
@@ -81,8 +82,8 @@ func NewAndroidDevice(options ...AndroidDeviceOption) (device *AndroidDevice, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
device = &AndroidDevice{
|
device = &AndroidDevice{
|
||||||
Port: UIA2ServerPort,
|
UIA2IP: UIA2ServerHost,
|
||||||
IP: AdbServerHost,
|
UIA2Port: UIA2ServerPort,
|
||||||
}
|
}
|
||||||
for _, option := range options {
|
for _, option := range options {
|
||||||
option(device)
|
option(device)
|
||||||
@@ -118,9 +119,8 @@ type AndroidDevice struct {
|
|||||||
d gadb.Device
|
d gadb.Device
|
||||||
logcat *AdbLogcat
|
logcat *AdbLogcat
|
||||||
SerialNumber string `json:"serial,omitempty" yaml:"serial,omitempty"`
|
SerialNumber string `json:"serial,omitempty" yaml:"serial,omitempty"`
|
||||||
IP string `json:"ip,omitempty" yaml:"ip,omitempty"`
|
UIA2IP string `json:"uia2_ip,omitempty" yaml:"uia2_ip,omitempty"` // uiautomator2 server ip
|
||||||
Port int `json:"port,omitempty" yaml:"port,omitempty"`
|
UIA2Port int `json:"uia2_port,omitempty" yaml:"uia2_port,omitempty"` // uiautomator2 server port
|
||||||
MjpegPort int `json:"mjpeg_port,omitempty" yaml:"mjpeg_port,omitempty"`
|
|
||||||
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
LogOn bool `json:"log_on,omitempty" yaml:"log_on,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,9 +174,8 @@ func (dev *AndroidDevice) NewUSBDriver(capabilities Capabilities) (driver *uiaDr
|
|||||||
_ = dev.d.ForwardKill(localPort)
|
_ = dev.d.ForwardKill(localPort)
|
||||||
return nil, errors.Wrap(code.AndroidDeviceUSBDriverError, err.Error())
|
return nil, errors.Wrap(code.AndroidDeviceUSBDriverError, err.Error())
|
||||||
}
|
}
|
||||||
driver.adbDevice = dev.d
|
driver.adbClient = dev.d
|
||||||
driver.logcat = dev.logcat
|
driver.logcat = dev.logcat
|
||||||
driver.localPort = localPort
|
|
||||||
|
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
@@ -184,11 +183,11 @@ func (dev *AndroidDevice) NewUSBDriver(capabilities Capabilities) (driver *uiaDr
|
|||||||
// NewHTTPDriver creates new remote HTTP client, this will also start a new session.
|
// NewHTTPDriver creates new remote HTTP client, this will also start a new session.
|
||||||
// TODO: replace uiaDriver with WebDriver
|
// TODO: replace uiaDriver with WebDriver
|
||||||
func (dev *AndroidDevice) NewHTTPDriver(capabilities Capabilities) (driver *uiaDriver, err error) {
|
func (dev *AndroidDevice) NewHTTPDriver(capabilities Capabilities) (driver *uiaDriver, err error) {
|
||||||
rawURL := fmt.Sprintf("http://%s:%d/wd/hub", dev.IP, dev.Port)
|
rawURL := fmt.Sprintf("http://%s:%d/wd/hub", dev.UIA2IP, dev.UIA2Port)
|
||||||
if driver, err = NewUIADriver(capabilities, rawURL); err != nil {
|
if driver, err = NewUIADriver(capabilities, rawURL); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
driver.adbDevice = dev.d
|
driver.adbClient = dev.d
|
||||||
return driver, nil
|
return driver, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,8 @@ var errDriverNotImplemented = errors.New("driver method not implemented")
|
|||||||
type uiaDriver struct {
|
type uiaDriver struct {
|
||||||
Driver
|
Driver
|
||||||
|
|
||||||
adbDevice gadb.Device
|
adbClient gadb.Device
|
||||||
logcat *AdbLogcat
|
logcat *AdbLogcat
|
||||||
localPort int
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewUIADriver(capabilities Capabilities, urlPrefix string) (driver *uiaDriver, err error) {
|
func NewUIADriver(capabilities Capabilities, urlPrefix string) (driver *uiaDriver, err error) {
|
||||||
@@ -126,44 +125,6 @@ func (ud *uiaDriver) NewSession(capabilities Capabilities) (sessionInfo SessionI
|
|||||||
return SessionInfo{SessionId: sessionID}, nil
|
return SessionInfo{SessionId: sessionID}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ud *uiaDriver) ActiveSession() (sessionInfo SessionInfo, err error) {
|
|
||||||
// [[FBRoute GET:@""] respondWithTarget:self action:@selector(handleGetActiveSession:)]
|
|
||||||
return SessionInfo{SessionId: ud.sessionId}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ud *uiaDriver) SessionIDs() (sessionIDs []string, err error) {
|
|
||||||
// register(getHandler, new GetSessions("/wd/hub/sessions"))
|
|
||||||
var rawResp rawResponse
|
|
||||||
if rawResp, err = ud.httpGET("/sessions"); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
reply := new(struct{ Value []struct{ SessionId string } })
|
|
||||||
if err = json.Unmarshal(rawResp, reply); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
sessionIDs = make([]string, len(reply.Value))
|
|
||||||
for i := range reply.Value {
|
|
||||||
sessionIDs[i] = reply.Value[i].SessionId
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ud *uiaDriver) SessionDetails() (scrollData map[string]interface{}, err error) {
|
|
||||||
// register(getHandler, new GetSessionDetails("/wd/hub/session/:sessionId"))
|
|
||||||
var rawResp rawResponse
|
|
||||||
if rawResp, err = ud.httpGET("/session", ud.sessionId); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
reply := new(struct{ Value map[string]interface{} })
|
|
||||||
if err = json.Unmarshal(rawResp, reply); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollData = reply.Value
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ud *uiaDriver) DeleteSession() (err error) {
|
func (ud *uiaDriver) DeleteSession() (err error) {
|
||||||
// TODO
|
// TODO
|
||||||
return errDriverNotImplemented
|
return errDriverNotImplemented
|
||||||
@@ -225,7 +186,7 @@ func (ud *uiaDriver) BatteryInfo() (batteryInfo BatteryInfo, err error) {
|
|||||||
|
|
||||||
func (ud *uiaDriver) WindowSize() (size Size, err error) {
|
func (ud *uiaDriver) WindowSize() (size Size, err error) {
|
||||||
// adb shell wm size
|
// adb shell wm size
|
||||||
resp, err := ud.adbDevice.RunShellCommand("wm", "size")
|
resp, err := ud.adbClient.RunShellCommand("wm", "size")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
// Physical size: 1080x2340
|
// Physical size: 1080x2340
|
||||||
s := strings.Trim(strings.Split(resp, ": ")[1], "\n")
|
s := strings.Trim(strings.Split(resp, ": ")[1], "\n")
|
||||||
@@ -261,7 +222,7 @@ func (ud *uiaDriver) Scale() (scale float64, err error) {
|
|||||||
// PressBack simulates a short press on the BACK button.
|
// PressBack simulates a short press on the BACK button.
|
||||||
func (ud *uiaDriver) PressBack(options ...DataOption) (err error) {
|
func (ud *uiaDriver) PressBack(options ...DataOption) (err error) {
|
||||||
// adb shell input keyevent 4
|
// adb shell input keyevent 4
|
||||||
_, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_BACK)
|
_, err = ud.adbClient.RunShellCommand("input", "keyevent", KEYCODE_BACK)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -271,33 +232,33 @@ func (ud *uiaDriver) PressBack(options ...DataOption) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ud *uiaDriver) StartCamera() (err error) {
|
func (ud *uiaDriver) StartCamera() (err error) {
|
||||||
if _, err = ud.adbDevice.RunShellCommand("rm", "-r", "/sdcard/DCIM/Camera"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("rm", "-r", "/sdcard/DCIM/Camera"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
var version string
|
var version string
|
||||||
if version, err = ud.adbDevice.RunShellCommand("getprop", "ro.build.version.release"); err != nil {
|
if version, err = ud.adbClient.RunShellCommand("getprop", "ro.build.version.release"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if version == "11" || version == "12" {
|
if version == "11" || version == "12" {
|
||||||
if _, err = ud.adbDevice.RunShellCommand("am", "start", "-a", "android.media.action.STILL_IMAGE_CAMERA"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("am", "start", "-a", "android.media.action.STILL_IMAGE_CAMERA"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("input", "swipe", "750", "1000", "250", "1000"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("input", "swipe", "750", "1000", "250", "1000"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if _, err = ud.adbDevice.RunShellCommand("am", "start", "-a", "android.media.action.VIDEO_CAPTURE"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("am", "start", "-a", "android.media.action.VIDEO_CAPTURE"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
time.Sleep(5 * time.Second)
|
time.Sleep(5 * time.Second)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("input", "keyevent", KEYCODE_CAMERA); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -315,12 +276,12 @@ func (ud *uiaDriver) StopCamera() (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// kill samsung shell command
|
// kill samsung shell command
|
||||||
if _, err = ud.adbDevice.RunShellCommand("am", "force-stop", "com.sec.android.app.camera"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("am", "force-stop", "com.sec.android.app.camera"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// kill other camera (huawei mi)
|
// kill other camera (huawei mi)
|
||||||
if _, err = ud.adbDevice.RunShellCommand("am", "force-stop", "com.android.camera2"); err != nil {
|
if _, err = ud.adbClient.RunShellCommand("am", "force-stop", "com.android.camera2"); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
@@ -332,7 +293,7 @@ func (ud *uiaDriver) Homescreen() (err error) {
|
|||||||
|
|
||||||
func (ud *uiaDriver) PressKeyCode(keyCode KeyCode, metaState KeyMeta, flags ...KeyFlag) (err error) {
|
func (ud *uiaDriver) PressKeyCode(keyCode KeyCode, metaState KeyMeta, flags ...KeyFlag) (err error) {
|
||||||
// adb shell input keyevent <keyCode>
|
// adb shell input keyevent <keyCode>
|
||||||
_, err = ud.adbDevice.RunShellCommand(
|
_, err = ud.adbClient.RunShellCommand(
|
||||||
"input", "keyevent", fmt.Sprintf("%d", keyCode))
|
"input", "keyevent", fmt.Sprintf("%d", keyCode))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -355,7 +316,7 @@ func (ud *uiaDriver) PressKeyCode(keyCode KeyCode, metaState KeyMeta, flags ...K
|
|||||||
func (ud *uiaDriver) AppLaunch(bundleId string) (err error) {
|
func (ud *uiaDriver) AppLaunch(bundleId string) (err error) {
|
||||||
// 不指定 Activity 名称启动(启动主 Activity)
|
// 不指定 Activity 名称启动(启动主 Activity)
|
||||||
// adb shell monkey -p <packagename> -c android.intent.category.LAUNCHER 1
|
// adb shell monkey -p <packagename> -c android.intent.category.LAUNCHER 1
|
||||||
sOutput, err := ud.adbDevice.RunShellCommand(
|
sOutput, err := ud.adbClient.RunShellCommand(
|
||||||
"monkey", "-p", bundleId, "-c", "android.intent.category.LAUNCHER", "1",
|
"monkey", "-p", bundleId, "-c", "android.intent.category.LAUNCHER", "1",
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -370,7 +331,7 @@ func (ud *uiaDriver) AppLaunch(bundleId string) (err error) {
|
|||||||
func (ud *uiaDriver) AppTerminate(bundleId string) (successful bool, err error) {
|
func (ud *uiaDriver) AppTerminate(bundleId string) (successful bool, err error) {
|
||||||
// 强制停止应用,停止 <packagename> 相关的进程
|
// 强制停止应用,停止 <packagename> 相关的进程
|
||||||
// adb shell am force-stop <packagename>
|
// adb shell am force-stop <packagename>
|
||||||
_, err = ud.adbDevice.RunShellCommand("am", "force-stop", bundleId)
|
_, err = ud.adbClient.RunShellCommand("am", "force-stop", bundleId)
|
||||||
return err == nil, err
|
return err == nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -380,7 +341,7 @@ func (ud *uiaDriver) Tap(x, y int, options ...DataOption) error {
|
|||||||
|
|
||||||
func (ud *uiaDriver) TapFloat(x, y float64, options ...DataOption) (err error) {
|
func (ud *uiaDriver) TapFloat(x, y float64, options ...DataOption) (err error) {
|
||||||
// adb shell input tap x y
|
// adb shell input tap x y
|
||||||
_, err = ud.adbDevice.RunShellCommand(
|
_, err = ud.adbClient.RunShellCommand(
|
||||||
"input", "tap", fmt.Sprintf("%.1f", x), fmt.Sprintf("%.1f", y))
|
"input", "tap", fmt.Sprintf("%.1f", x), fmt.Sprintf("%.1f", y))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return nil
|
return nil
|
||||||
@@ -461,7 +422,7 @@ func (ud *uiaDriver) Swipe(fromX, fromY, toX, toY int, options ...DataOption) er
|
|||||||
|
|
||||||
func (ud *uiaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...DataOption) error {
|
func (ud *uiaDriver) SwipeFloat(fromX, fromY, toX, toY float64, options ...DataOption) error {
|
||||||
// adb shell input swipe fromX fromY toX toY
|
// adb shell input swipe fromX fromY toX toY
|
||||||
_, err := ud.adbDevice.RunShellCommand(
|
_, err := ud.adbClient.RunShellCommand(
|
||||||
"input", "swipe",
|
"input", "swipe",
|
||||||
fmt.Sprintf("%.1f", fromX), fmt.Sprintf("%.1f", fromY),
|
fmt.Sprintf("%.1f", fromX), fmt.Sprintf("%.1f", fromY),
|
||||||
fmt.Sprintf("%.1f", toX), fmt.Sprintf("%.1f", toY),
|
fmt.Sprintf("%.1f", toX), fmt.Sprintf("%.1f", toY),
|
||||||
@@ -581,7 +542,7 @@ func (ud *uiaDriver) SetRotation(rotation Rotation) (err error) {
|
|||||||
|
|
||||||
func (ud *uiaDriver) Screenshot() (raw *bytes.Buffer, err error) {
|
func (ud *uiaDriver) Screenshot() (raw *bytes.Buffer, err error) {
|
||||||
// adb shell screencap -p
|
// adb shell screencap -p
|
||||||
resp, err := ud.adbDevice.RunShellCommandWithBytes(
|
resp, err := ud.adbClient.RunShellCommandWithBytes(
|
||||||
"screencap", "-p",
|
"screencap", "-p",
|
||||||
)
|
)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|||||||
@@ -66,43 +66,6 @@ func TestDriver_Status(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDriver_SessionIDs(t *testing.T) {
|
|
||||||
driver, err := NewUIADriver(nil, uiaServerURL)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
sessions, err := driver.SessionIDs()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(sessions) == 0 {
|
|
||||||
t.Fatal("should have at least one")
|
|
||||||
}
|
|
||||||
t.Log(len(sessions), sessions)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDriver_SessionDetails(t *testing.T) {
|
|
||||||
// firstMatchEntry := make(map[string]interface{})
|
|
||||||
// firstMatchEntry["package"] = "com.android.settings"
|
|
||||||
// firstMatchEntry["activity"] = "com.android.settings/.Settings"
|
|
||||||
// caps = Capabilities{
|
|
||||||
// "firstMatch": []interface{}{firstMatchEntry},
|
|
||||||
// "alwaysMatch": struct{}{},
|
|
||||||
// }
|
|
||||||
driver, err := NewUIADriver(nil, uiaServerURL)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
scrollData, err := driver.SessionDetails()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
t.Log(scrollData)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestDriver_Screenshot(t *testing.T) {
|
func TestDriver_Screenshot(t *testing.T) {
|
||||||
driver, err := NewUIADriver(nil, uiaServerURL)
|
driver, err := NewUIADriver(nil, uiaServerURL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -595,7 +595,6 @@ type WebDriver interface {
|
|||||||
// NewSession starts a new session and returns the SessionInfo.
|
// NewSession starts a new session and returns the SessionInfo.
|
||||||
NewSession(capabilities Capabilities) (SessionInfo, error)
|
NewSession(capabilities Capabilities) (SessionInfo, error)
|
||||||
|
|
||||||
ActiveSession() (SessionInfo, error)
|
|
||||||
// DeleteSession Kills application associated with that session and removes session
|
// DeleteSession Kills application associated with that session and removes session
|
||||||
// 1) alertsMonitor disable
|
// 1) alertsMonitor disable
|
||||||
// 2) testedApplicationBundleId terminate
|
// 2) testedApplicationBundleId terminate
|
||||||
|
|||||||
@@ -69,18 +69,6 @@ func (wd *wdaDriver) NewSession(capabilities Capabilities) (sessionInfo SessionI
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (wd *wdaDriver) ActiveSession() (sessionInfo SessionInfo, err error) {
|
|
||||||
// [[FBRoute GET:@""] respondWithTarget:self action:@selector(handleGetActiveSession:)]
|
|
||||||
var rawResp rawResponse
|
|
||||||
if rawResp, err = wd.httpGET("/session", wd.sessionId); err != nil {
|
|
||||||
return SessionInfo{}, err
|
|
||||||
}
|
|
||||||
if sessionInfo, err = rawResp.valueConvertToSessionInfo(); err != nil {
|
|
||||||
return SessionInfo{}, err
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func (wd *wdaDriver) DeleteSession() (err error) {
|
func (wd *wdaDriver) DeleteSession() (err error) {
|
||||||
// [[FBRoute DELETE:@""] respondWithTarget:self action:@selector(handleDeleteSession:)]
|
// [[FBRoute DELETE:@""] respondWithTarget:self action:@selector(handleDeleteSession:)]
|
||||||
_, err = wd.httpDELETE("/session", wd.sessionId)
|
_, err = wd.httpDELETE("/session", wd.sessionId)
|
||||||
|
|||||||
@@ -68,18 +68,6 @@ func TestNewUSBDriver(t *testing.T) {
|
|||||||
// t.Log(driver.IsWdaHealthy())
|
// t.Log(driver.IsWdaHealthy())
|
||||||
}
|
}
|
||||||
|
|
||||||
func Test_remoteWD_ActiveSession(t *testing.T) {
|
|
||||||
setup(t)
|
|
||||||
|
|
||||||
sessionInfo, err := driver.ActiveSession()
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
if len(sessionInfo.SessionId) == 0 {
|
|
||||||
t.Fatal(sessionInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func Test_remoteWD_DeleteSession(t *testing.T) {
|
func Test_remoteWD_DeleteSession(t *testing.T) {
|
||||||
setup(t)
|
setup(t)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user